📄 calculator.java
字号:
package calculator;import java.awt.*;import java.awt.event.*;import java.applet.*;public class Calculator extends Applet { boolean isStandalone = false; TextField textField1 = new TextField(); Button button1 = new Button(); 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(); /**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 Calculator() { } /**Initialize the applet*/ public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { textField1.setText("0"); textField1.setBounds(new Rectangle(13, 19, 283, 32)); this.setLayout(null); button1.setLabel("7"); button1.setBounds(new Rectangle(18, 62, 64, 31)); button2.setLabel("8"); button2.setBounds(new Rectangle(84, 62, 65, 31)); button3.setLabel("9"); button3.setBounds(new Rectangle(151, 62, 64, 32)); button4.setLabel("/"); button4.setBounds(new Rectangle(217, 62, 68, 32)); button5.setLabel("4"); button5.setBounds(new Rectangle(18, 94, 64, 32)); button6.setLabel("5"); button6.setBounds(new Rectangle(85, 94, 64, 32)); button7.setLabel("6"); button7.setBounds(new Rectangle(150, 94, 66, 32)); button8.setLabel("*"); button8.setBounds(new Rectangle(218, 95, 67, 31)); button9.setLabel("1"); button9.setBounds(new Rectangle(18, 127, 64, 32)); button10.setLabel("2"); button10.setBounds(new Rectangle(84, 127, 65, 32)); button11.setLabel("3"); button11.setBounds(new Rectangle(151, 127, 65, 32)); button12.setLabel("-"); button12.setBounds(new Rectangle(218, 127, 67, 32)); button13.setLabel("0"); button13.setBounds(new Rectangle(18, 160, 64, 34)); button14.setLabel("."); button14.setBounds(new Rectangle(85, 161, 64, 34)); button15.setLabel("="); button15.setBounds(new Rectangle(151, 160, 66, 35)); button16.setLabel("+"); button16.setBounds(new Rectangle(219, 160, 66, 35)); this.add(textField1, null); this.add(button1, null); this.add(button2, null); this.add(button3, null); this.add(button4, null); this.add(button5, null); this.add(button6, null); this.add(button7, null); this.add(button8, null); this.add(button9, null); this.add(button10, null); this.add(button11, null); this.add(button12, null); this.add(button13, null); this.add(button14, null); this.add(button15, null); this.add(button16, null); } /**Start the applet*/ public void start() { } /**Stop the applet*/ public void stop() { } /**Destroy the applet*/ public void destroy() { } /**Get Applet information*/ public String getAppletInfo() { return "Applet Information"; } /**Get parameter info*/ public String[][] getParameterInfo() { return null; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -