diff --git a/.idea/modules.xml b/.idea/modules.xml index 8c68c6b..5f24dd5 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,6 +3,7 @@ + diff --git a/jisuan/jisuan.iml b/jisuan/jisuan.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/jisuan/jisuan.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/jisuan/src/Main.java b/jisuan/src/Main.java new file mode 100644 index 0000000..3e59c38 --- /dev/null +++ b/jisuan/src/Main.java @@ -0,0 +1,5 @@ +public class Main { + public static void main(String[] args) { + System.out.println("Hello world!"); + } +} \ No newline at end of file diff --git a/jisuan/src/jisuan1.java b/jisuan/src/jisuan1.java new file mode 100644 index 0000000..6f7cfb1 --- /dev/null +++ b/jisuan/src/jisuan1.java @@ -0,0 +1,211 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class jisuan1{ + public static void main(String[] args) { + JS win=new JS(); + } +} +class JS extends JFrame implements ActionListener{ + private StringBuilder sBuilder = new StringBuilder(); + JTextArea text=new JTextArea(); + double a,b; + Double sum; + int i; + public JS() + { + setBounds(100,100,400,400); + setTitle("计算器"); + this.setLayout(new BorderLayout()); + JPanel p1=new JPanel(); + JPanel p2=new JPanel(); + text.setPreferredSize(new Dimension (370,60)); + p2.setLayout(new FlowLayout()); + p1.add(text); + this.add(p1,BorderLayout.NORTH); + + + p2.setLayout(new GridLayout(5,4)); + JButton button[]=new JButton[20]; + button[0]=new JButton("C"); + button[1]=new JButton(" "); + button[2]=new JButton("%"); + button[3]=new JButton("÷"); + button[4]=new JButton("7"); + button[5]=new JButton("8"); + button[6]=new JButton("9"); + button[7]=new JButton("x"); + button[8]=new JButton("4"); + button[9]=new JButton("5"); + button[10]=new JButton("6"); + button[11]=new JButton("—"); + button[12]=new JButton("1"); + button[13]=new JButton("2"); + button[14]=new JButton("3"); + button[15]=new JButton("+"); + button[16]=new JButton(""); + button[17]=new JButton("0"); + button[18]=new JButton("."); + button[19]=new JButton("="); + + for(int i=0;i