the type must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent)
packageJPanel;importjavax.swing.*;importjava.awt.event.*;publicclasstest5extendsJFram...
package JPanel;
import javax.swing.*;
import java.awt.event.*;
public class test5 extends JFrame implements ActionListener
{
JButton jb=new JButton();
int i=0;
public test5()
{
this.setTitle("创建按钮");
jb.setText("按钮按了0次");
jb.setMnemonic('a');
this.add(jb);
jb.addActionListener(this);
this.setBounds(300,250,300,200);
this.setVisible(true);
public void avtionPerformed(ActionEvent e)
{
this.jb.setText("按钮按了"+(++i)+"次");
}
public static void main(String args[])
{
test5 t=new test5();
}
}
写这个的时候在test5处报错the type must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent)
求指导 展开
import javax.swing.*;
import java.awt.event.*;
public class test5 extends JFrame implements ActionListener
{
JButton jb=new JButton();
int i=0;
public test5()
{
this.setTitle("创建按钮");
jb.setText("按钮按了0次");
jb.setMnemonic('a');
this.add(jb);
jb.addActionListener(this);
this.setBounds(300,250,300,200);
this.setVisible(true);
public void avtionPerformed(ActionEvent e)
{
this.jb.setText("按钮按了"+(++i)+"次");
}
public static void main(String args[])
{
test5 t=new test5();
}
}
写这个的时候在test5处报错the type must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent)
求指导 展开
1个回答
展开全部
public void avtionPerformed(ActionEvent e)
{
this.jb.setText("按钮按了"+(++i)+"次");
} 把这个方法拿出去
-------------------------------------------
package JPanel;
import javax.swing.*;
import java.awt.event.*;
public class test5 extends JFrame implements ActionListener
{
JButton jb=new JButton();
int i=0;
public test5()
{
this.setTitle("创建按钮");
jb.setText("按钮按了0次");
jb.setMnemonic('a');
this.add(jb);
jb.addActionListener(this);
this.setBounds(300,250,300,200);
this.setVisible(true);
}
public static void main(String args[])
{
test5 t=new test5();
}
public void avtionPerformed(ActionEvent e)
{
this.jb.setText("按钮按了"+(++i)+"次");
}
}
{
this.jb.setText("按钮按了"+(++i)+"次");
} 把这个方法拿出去
-------------------------------------------
package JPanel;
import javax.swing.*;
import java.awt.event.*;
public class test5 extends JFrame implements ActionListener
{
JButton jb=new JButton();
int i=0;
public test5()
{
this.setTitle("创建按钮");
jb.setText("按钮按了0次");
jb.setMnemonic('a');
this.add(jb);
jb.addActionListener(this);
this.setBounds(300,250,300,200);
this.setVisible(true);
}
public static void main(String args[])
{
test5 t=new test5();
}
public void avtionPerformed(ActionEvent e)
{
this.jb.setText("按钮按了"+(++i)+"次");
}
}
追问
你好 我按你说的把这个方法拿出去了还是存在一样错误
如果把这个方法拿出去按照你写的这样,那会不会不执行这个方法?
追答
怎么可能,你试下再说;你这个方法名写错了
public void avtionPerformed(ActionEvent e)
{
this.jb.setText("按钮按了"+(++i)+"次");
}
改成:
public void actionPerformed(ActionEvent e) {
this.jb.setText("按钮按了"+(++i)+"次");
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询