📄 frame1.java~1~
字号:
jPanel4.add(jButton216, new XYConstraints(182, 138, 42, 23)); jPanel4.add(jButton212, new XYConstraints(122, 98, 42, -1)); jPanel4.add(jButton217, new XYConstraints(122, 138, 42, -1)); jPanel4.add(jButton213, new XYConstraints(62, 98, 42, -1)); jPanel4.add(jButton218, new XYConstraints(62, 138, 42, -1)); jPanel4.add(jButton214, new XYConstraints(6, 98, 42, -1)); jPanel4.add(jButton210, new XYConstraints(234, 96, 42, -1)); jPanel4.add(jButton26, new XYConstraints(180, 58, 42, -1)); jPanel4.add(jButton27, new XYConstraints(122, 58, 42, -1)); jPanel4.add(jButton23, new XYConstraints(181, 19, 42, 22)); jPanel4.add(jButton22, new XYConstraints(122, 19, 44, -1)); jPanel4.add(jButton21, new XYConstraints(62, 19, 42, -1)); jPanel4.add(jButton28, new XYConstraints(62, 58, 42, -1)); jPanel4.add(jButton29, new XYConstraints(6, 58, 42, -1)); jPanel4.add(jButton20, new XYConstraints(6, 19, 43, -1)); jPanel4.add(jLabel7, new XYConstraints(131, 164, 40, 14)); jPanel4.add(jLabel26, new XYConstraints(240, 4, 38, 12)); jPanel4.add(jLabel27, new XYConstraints(246, 44, 25, 12)); jPanel4.add(jLabel28, new XYConstraints(248, 82, 26, 14)); jPanel4.add(jLabel29, new XYConstraints(250, 124, 27, 14)); jPanel4.add(jLabel30, new XYConstraints(184, 2, 40, 16)); jPanel4.add(jLabel31, new XYConstraints(184, 42, 38, 16)); jPanel4.add(jLabel32, new XYConstraints(184, 84, 38, 12)); jPanel4.add(jLabel33, new XYConstraints(186, 124, 36, 14)); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } void jButton214_actionPerformed(ActionEvent e) { if(jTextField1.getText().equals("0")) //clear "0"; jTextField1.setText(""); if(isPowerOff){ // if the power is on. if(isInOff){ //clear the first number jTextField1.setText(""); } if(isResult){ isInOff = false; jTextField1.setText(jTextField1.getText()+e.getActionCommand()); } else{ jTextField1.setText(e.getActionCommand()); isResult = !isResult; isInOff = false; } } } void jButton217_actionPerformed(ActionEvent e) { if(jTextField1.getText().indexOf(".")<=0 && isPowerOff){ jTextField1.setText(jTextField1.getText()+e.getActionCommand()); } } void jButton4_actionPerformed(ActionEvent e) { jTextField1.setText("0"); isPowerOff = true; } void jButton3_actionPerformed(ActionEvent e) { jTextField1.setText(""); isPowerOff = false; } void jButton10_actionPerformed(ActionEvent e) { if(isPowerOff){ if(shift){ long result = 1; shift = false; isInOff = true; int num = Integer.parseInt(jTextField1.getText()); for(int i = 1;i<=num;i++) result *=i; jTextField1.setText(Long.toString(result)); } else{ jTextField1.setText("0"); } } } void jButton23_actionPerformed(ActionEvent e) { if(isPowerOff){ firstNum = Float.parseFloat(jTextField1.getText()); isDiv = true; isInOff = true; } } void jButton26_actionPerformed(ActionEvent e) { if(isPowerOff){ firstNum = Float.parseFloat(jTextField1.getText()); isMul = true; isInOff = true; } } void jButton211_actionPerformed(ActionEvent e) { if(!counter){ firstNum = Float.parseFloat(jTextField1.getText()); isAdd = true; isInOff = true; counter = true; } else{ endNum = firstNum; firstNum = Float.parseFloat(jTextField1.getText()); jTextField1.setText(Float.toString(firstNum+endNum)); isAdd = true; isInOff = true; counter = true; } } void jButton216_actionPerformed(ActionEvent e) { if(isPowerOff){ firstNum = Float.parseFloat(jTextField1.getText()); isSub = true; isInOff = true; } } void jButton215_actionPerformed(ActionEvent e) { endNum = Float.parseFloat(jTextField1.getText()); if(isAdd){ isAdd = false; jTextField1.setText(Float.toString(firstNum+endNum)); isInOff = true; } if(isMul){ isMul = false; jTextField1.setText(Float.toString(firstNum*endNum)); isInOff = true; } if(isDiv){ isDiv = false; isInOff = false; jTextField1.setText(Float.toString(firstNum/endNum)); } if(isSub){ isDiv = false; isInOff = false; jTextField1.setText(Float.toString(firstNum/endNum)); } if(isXY){ isXY = false; isInOff = false; jTextField1.setText(Double.toString(Math.pow(firstNum,endNum))); } } void jButton6_actionPerformed(ActionEvent e) { if(isPowerOff){ isInOff = true; //clear the number if(shift){ shift = false; double Num = Double.parseDouble(jTextField1.getText()); jTextField1.setText(Double.toString(Math.asin(Num))); } else{ double Num = Double.parseDouble(jTextField1.getText()); jTextField1.setText(Double.toString(Math.sin(Num))); } } } void jButton7_actionPerformed(ActionEvent e) { if(isPowerOff){ isInOff = true; //clear the number if(shift){ shift = false; double Num = Double.parseDouble(jTextField1.getText()); jTextField1.setText(Double.toString(Math.acos(Num))); } else{ double Num = Double.parseDouble(jTextField1.getText()); jTextField1.setText(Double.toString(Math.cos(Num))); } } } void jButton8_actionPerformed(ActionEvent e) { if(isPowerOff){ isInOff = true; //clear the number if(shift){ shift = false; double Num = Double.parseDouble(jTextField1.getText()); jTextField1.setText(Double.toString(Math.atan(Num))); } else { double Num = Double.parseDouble(jTextField1.getText()); jTextField1.setText(Double.toString(Math.tan(Num))); } } } void jButton12_actionPerformed(ActionEvent e) { if(isPowerOff){ isInOff = true; //clear the number if(shift){ shift = false; double Num = Double.parseDouble(jTextField1.getText()); jTextField1.setText(Double.toString(Math.pow(Math.E,Num))); } else{ double Num = Double.parseDouble(jTextField1.getText()); jTextField1.setText(Double.toString(Math.log(Num)/Math.log(Math.E))); } } } void jButton13_actionPerformed(ActionEvent e) { if(isPowerOff){ isInOff = true; //clear the number if(shift){ shift = false; double Num = Double.parseDouble(jTextField1.getText()); jTextField1.setText(Double.toString(Math.pow(10,Num))); } else{ double Num = Double.parseDouble(jTextField1.getText()); jTextField1.setText(Double.toString(Math.log(Num))); } } } void jButton19_actionPerformed(ActionEvent e) { if(isPowerOff){ double Num = Double.parseDouble(jTextField1.getText()); jTextField1.setText(Double.toString(Math.sqrt(Num))); isInOff = true; //clear the number } } void jButton110_actionPerformed(ActionEvent e) { if(isPowerOff){ isInOff = true; //clear the number if(shift){ shift = false; double Num = Double.parseDouble(jTextField1.getText()); jTextField1.setText(Double.toString(1/Num)); } else{ double Num = Double.parseDouble(jTextField1.getText()); jTextField1.setText(Double.toString(Num*Num)); } } } void jButton16_actionPerformed(ActionEvent e) { if(jTextField1.getText().length()>0&& isPowerOff){ jTextField1.setText(jTextField1.getText().substring(0,jTextField1.getText().length()-1)); } } void jButton17_actionPerformed(ActionEvent e) { if(isPowerOff){ isInOff = true; //clear the number if(shift){ shift = false; jTextField1.setText(Double.toString(Math.PI)); } else{ double Num = Double.parseDouble(jTextField1.getText()); jTextField1.setText(Double.toString(Math.exp(Num))); } } } void jButton2_actionPerformed(ActionEvent e) { if(isPowerOff){ shift = true; jTextField2.setText("2ndF"); } } void jButton18_actionPerformed(ActionEvent e) { if(isPowerOff){ firstNum = Float.parseFloat(jTextField1.getText()); if(shift){ shift = false; } else{ isXY = true; isInOff = true; } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -