计算器是我们身边最常用的工具,针对计算器的编写是很基础的,对于现在自己刚学完Java SE,更多的重要的知识还接触不到,话不多说————请君观阅我的文章
以下是计算机的编写代码
public class GUIMyFrame {
public static void show(final JFrame f,final int width,final int height){
SwingUtilities.invokeLater(new Runnable(){//invokeLater线程异步进行;invokeAndWait线程同步进行。
public void run(){
f.setTitle("计算机");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(width, height);
f.setVisible(true);
}
});
}
}
public class Jisuan extends JFrame {
JPanel one,two,three;
JButton jia,jian,cheng,
denghao1,chu,kuo1,kuo2,log,ln,q1,q2,q3,q4,q5,q6,q7,q8,q9,q0,dian,qing;
JTextField jie;
JLabel denghao;
JTextArea Area;
Jisuan(){
setLayout(new GridLayout(3,1,1,10));
one = new JPanel();
two = new JPanel();
three = new JPanel();
Area = new JTextArea(10,15);
jie = new JTextField(15);
jia = new JButton("+");
jian = new JButton("-");
cheng = new JButton("×");
chu = new JButton("÷");
denghao = new JLabel("等于",SwingConstants.CENTER);
denghao1 = new JButton("确认");
denghao.setForeground(Color.blue);
denghao1.setForeground(Color.red);
denghao.setFont(new Font("宋体",Font.BOLD,30));
jie.setEditable(false);
log = new JButton("%");
ln = new JButton("返回");
q1 = new JButton("1");
q2