Hello idols , im IT student beginner.
can anyone help me to make this applet organize like this : but wait first this is my code
import javax.swing.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Calculator extends Applet implements ActionListener {
Button btnAdd, btnSubtract, btnMultiply, btnDivide;
Label lblFirstDigit, lblSecondDigit, lblAnswer;
TextField txtFirstDigit, txtSecondDigit, txtAnswer;
public void init() {
lblFirstDigit = new Label("Enter the first integer: ");
txtFirstDigit = new TextField(10);
lblSecondDigit = new Label("Enter the second integer:");
txtSecondDigit = new TextField(10);
btnAdd = new Button("+");
btnSubtract = new Button("-");
btnMultiply = new Button("*");
btnDivide = new Button("/");
lblAnswer = new Label("Answer: ");
txtAnswer = new TextField(10);
add(lblFirstDigit);
add(txtFirstDigit);
add(lblSecondDigit);
add(txtSecondDigit);
add(btnAdd);
add(btnSubtract);
add(btnMultiply);
add(btnDivide);
add(lblAnswer);
add(txtAnswer);
btnAdd.addActionListener(this);
btnMultiply.addActionListener(this);
btnSubtract.addActionListener(this);
btnDivide.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
double firstDigit = Double.parseDouble(txtFirstDigit.getText());
double secondDigit = Double.parseDouble(txtSecondDigit.getText());
if (e.getSource() == btnAdd)
txtAnswer.setText(Double.toString(firstDigit+secon dDigit));
if (e.getSource() == btnSubtract)
txtAnswer.setText(Double.toString(firstDigit-secondDigit));
if (e.getSource() == btnMultiply)
txtAnswer.setText(Double.toString(firstDigit*secon dDigit));
if (e.getSource() == btnDivide)
txtAnswer.setText(Double.toString(firstDigit/secondDigit));
}
}
i cant do it like this :
541639_485416044858934_940158186_n.jpg
this is my output :
rgi.jpg