📜  科学计算器 GUI 的 java 代码 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:35.658000             🧑  作者: Mango

代码示例1
public class Gui extends JFrame {
    private static JButton [] button = new JButton[36];
    private static TextField tf;
    private JPanel panel;
    private JPanel panel1;



public Gui(){
    super("Scientific Calculator");
    panel = new JPanel();
    panel1 = new JPanel(new GridLayout(0,4));

    tf = new TextField(20);
    tf.setEditable(false);
    panel.add(tf);

    button[0]=new JButton("Rad/Deg");
    button[1]=new JButton("x!");
    button[2]=new JButton("sqrt");
    button[3]=new JButton("sin");
    button[4]=new JButton("cos");
    button[5]=new JButton("tan");
    button[6]=new JButton("ln");
    button[7]=new JButton("log");
    button[8]=new JButton("1/x");
    button[9]=new JButton("e^x");
    button[10]=new JButton("x^2");
    button[11]=new JButton("y^x");
    button[12]=new JButton("|x|");
    button[13]=new JButton("pi");
    button[14]=new JButton("e");

    button[15]=new JButton("C");
    button[16]=new JButton("(");
    button[17]=new JButton(")");
    button[18]=new JButton("%");
    button[19]=new JButton("/");
    button[20]=new JButton("7");
    button[21]=new JButton("8");
    button[22]=new JButton("9");
    button[23]=new JButton("*");
    button[24]=new JButton("4");
    button[25]=new JButton("5");
    button[26]=new JButton("6");
    button[27]=new JButton("-");
    button[28]=new JButton("1");
    button[29]=new JButton("2");
    button[30]=new JButton("3");
    button[31]=new JButton("+");
    button[32]=new JButton(".");
    button[33]=new JButton("0");
    button[34] =new JButton("+/-");
    button[35] =new JButton("=");



    for(int i = 0; i