package untitled1;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import com.borland.jbcl.layout.*;
public class calculatorupdate extends Applet {
double startnum;
boolean isResult = false;
boolean flagAdd = false;
boolean flagSub = false;
boolean flagMul = false;
boolean flagDiv = false;
double endnum;
String str = null;
boolean isStandalone = false;
Button button1 = new Button();
XYLayout xYLayout1 = new XYLayout();
Button button2 = new Button();
Button button3 = new Button();
Button button4 = new Button();
Button button5 = new Button();
Button button6 = new Button();
Button button7 = new Button();
Button button8 = new Button();
Button button9 = new Button();
Button button10 = new Button();
Button button11 = new Button();
Button button12 = new Button();
Button button13 = new Button();
Button button14 = new Button();
Button button15 = new Button();
Button button16 = new Button();
Button button17 = new Button();
TextField text = new TextField();
Button button18 = new Button();
Button button19 = new Button();
Button button20 = new Button();
Button button21 = new Button();
Button button22 = new Button();
/**Get a parameter value*/
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
/**Construct the applet*/
public calculatorupdate() {
}
/**Initialize the applet*/
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**Component initialization*/
private void jbInit() throws Exception {
button1.setFont(new java.awt.Font("Dialog", 0, 10));
button1.setLabel("1");
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
this.setLayout(xYLayout1);
button2.setFont(new java.awt.Font("Dialog", 0, 10));
button2.setLabel("2");
button2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
button3.setFont(new java.awt.Font("Dialog", 0, 10));
button3.setLabel("3");
button3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
button4.setFont(new java.awt.Font("Dialog", 0, 10));
button4.setLabel("4");
button4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
button5.setFont(new java.awt.Font("Dialog", 0, 10));
button5.setLabel("5");
button5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
button6.setFont(new java.awt.Font("Dialog", 0, 10));
button6.setLabel("6");
button6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
button7.setFont(new java.awt.Font("Dialog", 0, 10));
button7.setLabel("7");
button7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
button8.setFont(new java.awt.Font("Dialog", 0, 10));
button8.setLabel("8");
button8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
button9.setFont(new java.awt.Font("Dialog", 0, 10));
button9.setLabel("9");
button9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
button10.setFont(new java.awt.Font("Dialog", 0, 10));
button10.setLabel("0");
button10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
button11.setFont(new java.awt.Font("Dialog", 0, 10));
button11.setLabel(".");
button11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button11_actionPerformed(e);
}
});
button12.setFont(new java.awt.Font("Dialog", 0, 10));
button12.setLabel("+");
button12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button12_actionPerformed(e);
}
});
button13.setFont(new java.awt.Font("Dialog", 0, 10));
button13.setLabel("c");
button13.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button13_actionPerformed(e);
}
});
button14.setLabel("=");
button14.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button14_actionPerformed(e);
}
});
button15.setLabel("-");
button15.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button15_actionPerformed(e);
}
});
button16.setLabel("*");
button16.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button16_actionPerformed(e);
}
});
button17.setLabel("/");
button17.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button17_actionPerformed(e);
}
});
text.setEditable(false);
text.setText("0");
button18.setFont(new java.awt.Font("Dialog", 0, 8));
button18.setLabel("@");
button18.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button18_actionPerformed(e);
}
});
button19.setEnabled(false);
button19.setLabel("!");
button19.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button19_actionPerformed(e);
}
});
button20.setEnabled(false);
button20.setLabel("sin");
button20.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button20_actionPerformed(e);
}
});
button21.setEnabled(false);
button21.setLabel("cos");
button21.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button21_actionPerformed(e);
}
});
button22.setEnabled(false);
button22.setLabel("exp");
button22.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button22_actionPerformed(e);
}
});
this.add(button1, new XYConstraints(60, 50, 40, 40));
this.add(button2, new XYConstraints(120, 50, 40, 40));
this.add(button3, new XYConstraints(180, 50, 40, 40));
this.add(button4, new XYConstraints(60, 100, 40, 40));
this.add(button5, new XYConstraints(120, 100, 40, 40));
this.add(button6, new XYConstraints(180, 100, 40, 40));
this.add(button7, new XYConstraints(60, 150, 40, 40));
this.add(button8, new XYConstraints(120, 150, 40, 40));
this.add(button9, new XYConstraints(180, 150, 40, 40));
this.add(button10, new XYConstraints(60, 200, 40, 40));
this.add(button11, new XYConstraints(120, 200, 40, 40));
this.add(button12, new XYConstraints(180, 200, 40, 40));
this.add(button13, new XYConstraints(10, 50, 40, 40));
this.add(button14, new XYConstraints(230, 50, 50, 40));
this.add(button15, new
评论0