JButton b1=new JButton("打印");
b1.setBounds(80,140,100,50);
b1.setBorderPainted(false);
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JOptionPane.showMessageDialog(null,"弹出对话框");
}
});
Eclipse报错,错误为
ActionListener 无法解析为类型
- 类型 AbstractButton 中的方法 addActionListener(ActionListener)对于参数(new ActionListener()
{})不适用
这是怎么回事?感谢回答
第1个回答 2020-05-11
import java.awt.event.ActionListener;
第2个回答 2018-04-14
在你的与文件同名的类后面添加接口 implements ActionListener
第3个回答 推荐于2018-03-04
你导入错误的包了,我这样写好多次了都没问题 上面import删了ctrl + shift + o本回答被提问者和网友采纳
第4个回答 2014-12-30
代码没问题
是不是没有import相关的类
是不是没有import相关的类