From 1f11c14227530c21326c40d7d986cd98aed8b954 Mon Sep 17 00:00:00 2001 From: czldl Date: Sat, 19 Nov 2022 08:53:03 +0000 Subject: [PATCH] update GuiCalculator.java. v0.3 Signed-off-by: czldl --- GuiCalculator.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/GuiCalculator.java b/GuiCalculator.java index 54986ae..13b41b3 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