我这有个实现计算器功能的源码...是别人写的...谁帮我注释下...有些看不懂...谢谢啦....importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;classCTextendsWindowAdapter{...
我这有个实现计算器功能的源码...是别人写的...谁帮我注释下...有些看不懂...谢谢啦....import java.awt.*;import javax.swing.*;import java.awt.event.*;class CT extends WindowAdapter{ static JFrame f=new JFrame("计算器"); static JTextField text1=new JTextField("0."); static String source=""; static String cal=""; static String object=""; static boolean flag=false; static boolean flag1=true; static boolean flag2=false; public void init() { try { Container c=f.getContentPane(); JPanel pan1=new JPanel(); JButton b1=new JButton("1"); JButton b2=new JButton("2"); JButton b3=new JButton("3"); JButton b4=new JButton("4"); JButton b5=new JButton("5"); JButton b6=new JButton("6"); JButton b7=new JButton("7"); JButton b8=new JButton("8"); JButton b9=new JButton("9"); JButton b0=new JButton("0"); JButton b11=new JButton("+"); JButton b12=new JButton("-"); JButton b13=new JButton("*"); JButton b14=new JButton("/"); JButton b15=new JButton("."); JButton b16=new JButton("="); JButton bclar=new JButton("重置"); text1.setHorizontalAlignment(JTextField.RIGHT); c.add(text1,"North"); c.add(pan1); A aa=new A(); Result re=new Result(); Opertion op=new Opertion(); Clar cl=new Clar(); b1.addActionListener(aa); b2.addActionListener(aa); b3.addActionListener(aa); b4.addActionListener(aa); b5.addActionListener(aa); b6.addActionListener(aa); b7.addActionListener(aa); b8.addActionListener(aa); b9.addActionListener(aa); b0.addActionListener(aa); b11.addActionListener(op); b12.addActionListener(op); b13.addActionListener(op); b14.addActionListener(op); b16.addActionListener(re); b15.addActionListener(aa); bclar.addActionListener(cl);
展开