kakaka0
发贴: 6
积分: 0
|
于 2004-12-02 10:53
我的程序不知道什么错误,我是菜鸟帮帮忙吧!! import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Adder implements ActionListener { JFrame AdderFame; JTextField TOprand1; JTextField TOprand2; JLabel LAdd,LSum; JButton BAdd; int i=0; public Adder() { AdderFrame=new JFrame("AdderFrame"); TOprand1=new JTextField("0.0"); TOprand2=new JTextField("0.0"); LAdd=new JLabel("+"); LSum=new JLabel("= "); BAdd=new JButton("Add!"); AdderFrame.getContentPane().setLayout(new FlowLayout()); AdderFrame.getContentPane().add(TOprand1); AdderFrame.getContentPane().add(LAdd); AdderFrame.getContentPane().add(TOprand2); AdderFrame.getContentPane().add(LSum); AdderFrame.getContentPane().add(BAdd); AdderFrame.pack(); AdderFrame.setVisible(true); BAdd.addActionListener(this); public void actionPerformed(ActionEvent event) { i=(i=1)%2; if(i==1) { int sum=(int)(Double.valueOf(TOprand1.getText()).doubleValue()+Double.valueOf(TOprand.getText()).doubleValue()); LSum.setText("="+sum); }else{ TOpand1.setText("0.0"); TOpand2.serText("0.0"); LSum.setText("="); }; } AdderFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } public static void main(String[] args){ Adder adder=new Adder();} } 错误:--------------------Configuration: <Default>-------------------- C:\Adder.java:32: illegal start of expression public void ActionPerformed(ActionEvent event) ^ 1 error
Process completed.
|