写个程序但是提示有错误,可是能运行,,,却找不到错误
import java.awt.*;import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
class WindowButton extends JFrame implements ActionListener{
int number; //
JTextField inputNumber;
JLabel feedBack;
JButton buttonGetNumber,buttonEnter;
Timer timer;
int usedTime;
WindowButton(String s){
super(s);
buttonGetNumber=new JButton("得到一个随机数");
feedBack=new JLabel("无反馈信息",JLabel.CENTER);
feedBack.setBackground(Color.green);
inputNumber=new JTextField("0",5);
buttonEnter=new JButton("确定");
addActionListener1(buttonEnter);
buttonEnter.addActionListener(this);
addActionListener1(buttonGetNumber);
buttonGetNumber.addActionListener(this);
Box boxH1=Box.createHorizontalBox();
boxH1.add(new JLabel("获取1-100之间的随机数:"));
boxH1.add(buttonGetNumber);
Box boxH2=Box.createHorizontalBox();
boxH2.add(new JLabel("输入你的猜测:"));
boxH2.add(inputNumber);
Box boxH3=Box.createHorizontalBox();
boxH3.add(new JLabel("单击确定按钮:"));
boxH3.add(buttonEnter);
Box boxH4=Box.createHorizontalBox();
boxH4.add(new JLabel("反馈信息:"));
boxH4.add(feedBack);
Box baseBox=Box.createVerticalBox();
baseBox.add(boxH1);
baseBox.add(boxH2);
baseBox.add(boxH3);
baseBox.add(boxH4);
Container con=getContentPane();
con.setLayout(new FlowLayout());
con.add(baseBox);
con.validate();
setBounds(120,125,270,200);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100,100,150,150);
setVisible(true);
validate();
}
private void addActionListener1(JButton buttonGetNumber2) {
// TODO Auto-generated method stub
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==buttonGetNumber)//判断事件源是否是buttonGetNumber
number=(int)(Math.random()*100)+1;
else if(e.getSource()==buttonEnter){//判断事件源是否是buttonEnter
int guess=0;
try{
guess=Integer.parseInt(inputNumber.getText()); //返回inputNumber中的文本
if(guess==number){
feedBack.setText("猜对了!"); //feedBack设置提示文本“猜对了!”
}
else if(guess>number){
feedBack.setText("猜大了!"); //feedBack设置提示文本“猜大了!”
inputNumber.setText(null);
}
else if(guess<number){
feedBack.setText("猜小了!"); //feedBack设置提示文本“猜小了!”
inputNumber.setText(null);
}
}
catch(NumberFormatException event){
feedBack.setText("请输入数字字符:");//feedBack设置提示文本“请输入数字字符”
}
}
}
}
class GuessExample{
public static void main(String args[]){
new WindowButton("猜数字游戏");
}
}
怎么加个计时器在上面,还有统计次数怎么加啊