问题描述
我已经创建了一个JButton,并且每次单击它都想执行一个动作.我从Properties actionPerfomed中选择,然后尝试在函数内部编写代码.
I have created a JButton and I want to perform an action every time I click on it.I choose from Properties actionPerfomed and then I try to write the code inside the function.
private void OnMusicActionPerformed(java.awt.event.ActionEvent evt) {
MusicType = "on";
}
NetBeans不能识别ActionEvent的导入,建议我创建一个新类.怎么了?
NetBeans though doesn't recognize the imports for ActionEvent and suggests that I should create a new class.What is wrong?
推荐答案
如果您在问题中提供更多详细信息,将会很有帮助.
It'll be helpful if you provide little more details in you question.
我猜您需要另一个实现ActionListner的类,例如这样的东西:
I am guessing you need another class which implements ActionListner, for example something like this:
private class ACListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
此链接也应为您提供帮助:示例
This link should help you as well : examples
这篇关于Netbeans无法识别导入java.awt.event.ActionEvent和导入java.awt.event.ActionListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!