diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0548357 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..9bba0e8 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Computer.iml b/Computer.iml index 37cc804..c90834f 100644 --- a/Computer.iml +++ b/Computer.iml @@ -5,7 +5,7 @@ - + \ No newline at end of file diff --git a/src/computer/a.java b/src/computer/com.java similarity index 99% rename from src/computer/a.java rename to src/computer/com.java index 8b7b24d..22e9927 100644 --- a/src/computer/a.java +++ b/src/computer/com.java @@ -6,34 +6,29 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.text.MessageFormat; import java.util.Arrays; - -public class a { +public class com { public static void main(String[] args) { new JS(); } } - class JS extends JFrame implements ActionListener { private final StringBuilder sBuilder = new StringBuilder(); JTextArea text = new JTextArea(); double a, b; Double sum; String lastOperator = "="; - public JS() { setBounds(100, 100, 400, 400); setTitle("计算器"); JMenuBar menubar = new JMenuBar(); this.setJMenuBar(menubar); 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"); @@ -56,17 +51,14 @@ class JS extends JFrame implements ActionListener { button[17] = new JButton("0"); button[18] = new JButton("."); button[19] = new JButton("="); - Arrays.stream(button).forEach(p2::add); this.add(p2, BorderLayout.CENTER); - for (JButton jButton : button) { jButton.addActionListener(this); } this.setVisible(true); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } - public void actionPerformed(ActionEvent e) { String lab = e.getActionCommand(); @@ -93,7 +85,6 @@ class JS extends JFrame implements ActionListener { } } } - private void calculate() { switch (lastOperator) { case "+":