文件名称:java实现简单的计算器
文件大小:1KB
文件格式:RAR
更新时间:2013-07-19 16:27:59
计算器 java
简单实用的计算器,面板设计简单, public testZ(){ super("计算器"); setSize(300,240); Container con=getContentPane(); con.setLayout(new BorderLayout()); jPanel1=new JPanel(); jPanel1.setLayout(new GridLayout(1,1)); jPanel2=new JPanel(); jPanel2.setLayout(new GridLayout(4,4)); resultField=new JTextField("0"); jPanel1.add(resultField); con.add(jPanel1,BorderLayout.NORTH); s1=new JButton(" 1 "); s1.addActionListener(this); s2=new JButton(" 2 "); s2.addActionListener(this); s3=new JButton(" 3 "); s3.addActionListener(this); s4=new JButton(" 4 "); s4.addActionListener(this); s5=new JButton(" 5 "); s5.addActionListener(this); s6=new JButton(" 6 "); s6.addActionListener(this); s7=new JButton(" 7 "); s7.addActionListener(this); s8=new JButton(" 8 "); s8.addActionListener(this); s9=new JButton(" 9 "); s9.addActionListener(this); s0=new JButton(" 0 "); s0.addActionListener(this); b1=new JButton(" + "); b1.addActionListener(this); b2=new JButton(" - "); b2.addActionListener(this); b3=new JButton(" * "); b3.addActionListener(this); b4=new JButton(" / "); b4.addActionListener(this); f1=new JButton(" . "); f1.addActionListener(this); f2=new JButton(" = "); f2.addActionListener(this); jPanel2.add(s1); jPanel2.add(s2); jPanel2.add(s3); jPanel2.add(b1); jPanel2.add(s4); jPanel2.add(s5); jPanel2.add(s6); jPanel2.add(b2); jPanel2.add(s7); jPanel2.add(s8); jPanel2.add(s9); jPanel2.add(b3); jPanel2.add(s0); jPanel2.add(f1); jPanel2.add(f2); jPanel2.add(b4); con.add(jPanel2,BorderLayout.CENTER);
【文件预览】:
计算器.txt