import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
@SuppressWarnings("serial")
public class AppletTest extends JApplet{
private JButton b1 = new JButton("1");
private JButton b2 = new JButton("2");
private JButton b3 = new JButton("3");
private JButton b4 = new JButton("4");
private JButton b5 = new JButton("5");
private JButton b6 = new JButton("6");
private JButton b7 = new JButton("7");
private JButton b8 = new JButton("8");
private JButton b9 = new JButton("9");
private JButton b0 = new JButton("0");
private JButton b_add = new JButton("+");
private JButton b_sub = new JButton("-");
private JButton b_mult = new JButton("×");
private JButton b_div = new JButton("÷");
private JButton b_ce = new JButton("CE");
private JButton b_equal = new JButton("=");
private JTextField txt = new
JTextField(15);
private double number1,number2,temp,result;
private boolean add,sub,mult,div;
public void init(){
number1 = number2 = temp
=0.0;
add = sub = mult = div =
false;
JPanel area1 = new
JPanel();
area1.setLayout(new
GridLayout(4,3,2,2));
area1.add(b7);
area1.add(b8);
area1.add(b9);
area1.add(b4);
area1.add(b5);
area1.add(b6);
area1.add(b1);
area1.add(b2);
area1.add(b3);
area1.add(b0);
area1.add(b_ce);
area1.add(b_equal);
JPanel area2 = new
JPanel();
area2.setLayout(new
GridLayout(4,1,2,2));
area2.add(b_add);
area2.add(b_sub);
area2.add(b_mult);
area2.add(b_div);
JPanel show = new
JPanel();
show.add(txt);
Container cp =
getContentPane();
cp.add(BorderLayout.CENTER,area1);
cp.add(BorderLayout.EAST,area2);
cp.add(BorderLayout.NORTH,show);
b1.addActionListener(new
ActionListener(){
public void
actionPerformed(ActionEvent e) {
temp
= temp*10+1;
txt.setText(""+temp);
}
});
b2.addActionListener(new
ActionListener(){
public void
actionPerformed(ActionEvent e) {
temp
= temp*10+2;
txt.setText(""+temp);
}
});
b3.addActionListener(new
ActionListener(){
public void
actionPerformed(ActionEvent e) {
temp
= temp*10+3;
txt.setText(""+temp);
}
});
b4.addActionListener(new
ActionListener(){
public void
actionPerformed(ActionEvent e) {
temp
= temp*10+4;
txt.setText(""+temp);
}
});
b5.addActionListener(new
ActionListener(){
public void
actionPerformed(ActionEvent e) {
temp
= temp*10+5;
txt.setText(""+temp);
}
});
b6.addActionListener(new
ActionListener(){
public void
actionPerformed(ActionEvent e) {
temp
= temp*10+6;
txt.setText(""+temp);
}
});
b7.addActionListener(new
ActionListener(){
public void
actionPerformed(ActionEvent e) {
temp
= temp*10+7;
txt.setText(""+temp);
}
});
b8.addActionListener(new
ActionListener(){
public void
actionPerformed(ActionEvent e) {
temp
= temp*10+8;
txt.setText(""+temp);
}
});
b9.addActionListener(new
ActionListener(){
public void
actionPerformed(ActionEvent e) {
temp
= temp*10+9;
txt.setText(""+temp);
}