parent
787419f7db
commit
df442d4832
@ -0,0 +1,112 @@
|
||||
package Calculatorver2;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class CalculatorJFrame extends JFrame {
|
||||
public CalculatorJFrame(){
|
||||
initJFrame();
|
||||
|
||||
initJMenuBar();
|
||||
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
private void initJMenuBar(){
|
||||
JMenuBar Menu = new JMenuBar();
|
||||
|
||||
JMenu m1 = new JMenu("查看(V)");
|
||||
JMenu m2 = new JMenu("编辑(E)");
|
||||
JMenu m3 = new JMenu("帮助(H)");
|
||||
|
||||
JLabel l1 = new JLabel(" ".repeat(500));
|
||||
JLabel l2 = new JLabel(" ".repeat(500));
|
||||
JLabel l3 = new JLabel(" ".repeat(500));
|
||||
JLabel l4 = new JLabel(" ".repeat(500));
|
||||
JLabel l5 = new JLabel(" ".repeat(500));
|
||||
JLabel l6 = new JLabel(" ".repeat(500));
|
||||
|
||||
JTextField t1 = new JTextField(" 0");
|
||||
t1.setPreferredSize(new Dimension(300,60));
|
||||
|
||||
JButton b1 = new JButton("MC");
|
||||
JButton b2 = new JButton("MR");
|
||||
JButton b3 = new JButton("MS");
|
||||
JButton b4 = new JButton("M-");
|
||||
JButton b5 = new JButton("M+");
|
||||
JButton b6 = new JButton("<-- ");
|
||||
JButton b7 = new JButton("CE");
|
||||
JButton b8 = new JButton("C ");
|
||||
JButton b9 = new JButton("7 ");
|
||||
JButton b11 = new JButton("8 ");
|
||||
JButton b12 = new JButton("9 ");
|
||||
JButton b13 = new JButton("6 ");
|
||||
JButton b14 = new JButton("5 ");
|
||||
JButton b15 = new JButton("4 ");
|
||||
JButton b16 = new JButton("3 ");
|
||||
JButton b17 = new JButton("2 ");
|
||||
JButton b18 = new JButton("1 ");
|
||||
JButton b19 = new JButton("0 ");
|
||||
JButton b21 = new JButton("+ ");
|
||||
JButton b22 = new JButton("- ");
|
||||
JButton b23 = new JButton("* ");
|
||||
JButton b24 = new JButton("/ ");
|
||||
JButton b25 = new JButton("= ");
|
||||
JButton b26 = new JButton("% ");
|
||||
JButton b27 = new JButton(". ");
|
||||
JButton b28 = new JButton("1/x ");
|
||||
JButton b29 = new JButton("√ ");
|
||||
JButton b31 = new JButton("± ");
|
||||
|
||||
|
||||
Menu.add(m1);
|
||||
Menu.add(m2);
|
||||
Menu.add(m3);
|
||||
|
||||
this.add(t1);
|
||||
this.add(l1);
|
||||
this.add(b1);
|
||||
this.add(b2);
|
||||
this.add(b3);
|
||||
this.add(b5);
|
||||
this.add(b4);
|
||||
this.add(l2);
|
||||
this.add(b6);
|
||||
this.add(b7);
|
||||
this.add(b8);
|
||||
this.add(b29);
|
||||
this.add(b31);
|
||||
this.add(l3);
|
||||
this.add(b9);
|
||||
this.add(b11);
|
||||
this.add(b12);
|
||||
this.add(b24);
|
||||
this.add(b26);
|
||||
this.add(l4);
|
||||
this.add(b15);
|
||||
this.add(b14);
|
||||
this.add(b13);
|
||||
this.add(b23);
|
||||
this.add(b28);
|
||||
this.add(l5);
|
||||
this.add(b18);
|
||||
this.add(b17);
|
||||
this.add(b16);
|
||||
this.add(b22);
|
||||
this.add(b25);
|
||||
this.add(l6);
|
||||
this.add(b19);
|
||||
this.add(b27);
|
||||
this.add(b21);
|
||||
|
||||
this.setJMenuBar(Menu);
|
||||
}
|
||||
private void initJFrame() {
|
||||
this.setSize(425,450);
|
||||
this.setTitle("简易计算器");
|
||||
this.setLocationRelativeTo(null);
|
||||
this.setDefaultCloseOperation(3);
|
||||
this.setLayout(new FlowLayout());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in new issue