diff --git a/GuiCalculator.java b/GuiCalculator.java index 54986aea82ef7cfde15bb4d08c7ef21eb79460a7..13b41b30b97fe4fdcfe932978a609e914fb8969c 100644 --- a/GuiCalculator.java +++ b/GuiCalculator.java @@ -28,7 +28,7 @@ class CalculatorUI extends JFrame { private JTextField textField=new JTextField("0"); - private JPanel panel=new JPanel(new GridLayout(4,4)); + private JPanel panel=new JPanel(new GridLayout(5,4)); private JButton bt11=new JButton("7"); private JButton bt12=new JButton("8"); private JButton bt13=new JButton("9"); @@ -45,8 +45,12 @@ class CalculatorUI extends JFrame private JButton bt42=new JButton("."); private JButton bt43=new JButton("="); private JButton bt44=new JButton("+"); + private JButton bt51=new JButton("%"); + private JButton bt52=new JButton("!"); + private JButton bt53=new JButton("~"); + private JButton bt54=new JButton("^"); JButton jb[]={bt11,bt12,bt13,bt14,bt21,bt22,bt23,bt24, - bt31,bt32,bt33,bt34,bt41,bt42,bt43,bt44}; + bt31,bt32,bt33,bt34,bt41,bt42,bt43,bt44,bt51,bt52,bt53,bt54}; class MyHandler implements ActionListener { @@ -98,7 +102,7 @@ class CalculatorUI extends JFrame this.add(panel,BorderLayout.CENTER); panel.setPreferredSize(new Dimension(300,350)); - for(int i=0;i<16;i++){ + for(int i=0;i<20;i++){ jb[i].setFont(new Font("楷体",Font.BOLD,32)); panel.add(jb[i]); } @@ -107,7 +111,7 @@ class CalculatorUI extends JFrame private void ListenerAdd(MyHandler myHandler) { - for(int i=0;i<16;i++){ + for(int i=0;i<20;i++){ jb[i].addActionListener(myHandler); } } @@ -123,7 +127,7 @@ class CalcString for(int i=0;i