求助 程序 错在哪里?怎么改
程序代码:
import java.awt.event.*;
import java.awt.*;
public class AdapterCounter extends Frame{
private Button button=new Button("1");
public AdapterCounter(String title){
super(title);
//把MyMouseListener的实例注册为Button的监听器
button.addMouseListener(new MyMouseListener(2));
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent evt){
System.exit(0);//结束程序
}
});
add(button);
setSize(100,100);
setVisible(true);
}
public static void main(String[] agrs){
new AdapterCounter("Hello");
}
}
class MyMouseListener extends MouseAdapter{
private int step; //决定Button上的标号每次增加的步长
public MyMouseListener(int step){
this.step=step;
}
public void mousePressed(MouseEvent evt){
Button button=(Button)evt.getSource();
int count=Integer.parseInt(button.getLabel());
//把Button上的标号加step
button.setLabel(new Integer(step+count).toString());
}
}
import java.awt.*;
public class AdapterCounter extends Frame{
private Button button=new Button("1");
public AdapterCounter(String title){
super(title);
//把MyMouseListener的实例注册为Button的监听器
button.addMouseListener(new MyMouseListener(2));
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent evt){
System.exit(0);//结束程序
}
});
add(button);
setSize(100,100);
setVisible(true);
}
public static void main(String[] agrs){
new AdapterCounter("Hello");
}
}
class MyMouseListener extends MouseAdapter{
private int step; //决定Button上的标号每次增加的步长
public MyMouseListener(int step){
this.step=step;
}
public void mousePressed(MouseEvent evt){
Button button=(Button)evt.getSource();
int count=Integer.parseInt(button.getLabel());
//把Button上的标号加step
button.setLabel(new Integer(step+count).toString());
}
}
----------------解决方案--------------------------------------------------------
你想问什么?
没发现什么错无啊?
----------------解决方案--------------------------------------------------------