Java : 未覆盖ActionListener中的抽象方法?
请高手帮忙看下哪里有问题:importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;//importMyWi...
请高手帮忙看下哪里有问题:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
//import MyWindowListener
public class ButtonEvent extends JFrame implements ActionListener
{
JButton button=new JButton("Click Me");
JTextArea textArea=new JTextArea(2,20);
Container c; //容器
int clickCount=0;
public ButtonEvent(){
super("ButtonEvent.java");
c=getContentPane();
c.setLayout(new FlowLayout());
c.add(button);
c.add(textArea);
this.setSize(300,120);
this.setVisible(true);
button.addActionListener(this);
}
public void acionPerformed(ActionEvent e){
clickCount++;
textArea.setText("你按了"+clickCount+"次");
}
public static void main(String args[]){
ButtonEvent app=new ButtonEvent();
app.addWindowListener(new MyWindowListener());
}
} 展开
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
//import MyWindowListener
public class ButtonEvent extends JFrame implements ActionListener
{
JButton button=new JButton("Click Me");
JTextArea textArea=new JTextArea(2,20);
Container c; //容器
int clickCount=0;
public ButtonEvent(){
super("ButtonEvent.java");
c=getContentPane();
c.setLayout(new FlowLayout());
c.add(button);
c.add(textArea);
this.setSize(300,120);
this.setVisible(true);
button.addActionListener(this);
}
public void acionPerformed(ActionEvent e){
clickCount++;
textArea.setText("你按了"+clickCount+"次");
}
public static void main(String args[]){
ButtonEvent app=new ButtonEvent();
app.addWindowListener(new MyWindowListener());
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |