I wanted to know how I can make the text of my labels bigger and put breaks in between of the labels. So basically for the code I want it to be:
(Big) Ohms Law
(A bit smaller) Voltage (textbox + button here)
(Same size as Voltage) Resistance (textbox + button here)
So far I have this:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class OhmsLawApplet extends Applet implements ActionListener
{
// declare variables
int RESISTANCE;
int VOLTAGE;
int OHMS;
int V = 0;
int R = 0;
int I = 0;
//construct components
Label OhmsLabel = new Label("Ohms Law"); // Label at the top
Label VOLTAGELabel = new Label("Voltage:"); // Label for Voltage
TextField VOLTAGEField = new TextField(); //Textfield to input Voltage
Label RESISTANCELabel = new Label("Resistance:"); // Label for Resistance
TextField RESISTANCEField = new TextField(); //Textfield to input Resistance
Button CALCULATEButton = new Button("Calculate");
public void init(){
// Add the components to the Applet
setForeground(Color.black);
add(OhmsLabel);
add(VOLTAGELabel);
add(VOLTAGEField);
add(RESISTANCELabel);
add(RESISTANCEField);
add(CALCULATEButton);
CALCULATEButton.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
// UNFINISHED/ DON'T KNOW HOW TO DO YET
VOLTAGE = Integer.parseInt(VOLTAGEField.getText());
RESISTANCE = Integer.parseInt(RESISTANCEField.getText());
VOLTAGE = I*R;
RESISTANCE = V/I;
}
}