问题描述
当一个 JButton
被添加到内容窗格时,我们可以通过双击按钮或右键单击->事件->动作->actionPerformed来设置一个动作.比如说,我们设置一些东西发生.然后我们需要删除该函数.删除我们在该按钮的 actionPerformed 中编写的代码可以轻松完成.但问题是,那个按钮的 actionPerformed 方法仍然存在,即使它不再被使用,也不需要了.
When a JButton
is added to a content pane, we can set an action by double clicking the button or Right click->Event->Action->actionPerformed.Let say, we set somthing to happen. Then we need to remove that function.It can be done easily by deleting the code we wrote in that buttton's actionPerformed. But the problem is, that button's actionPerformed method is still there even though it is not used any more and not needed.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
//no function here.. but this code is still remaining. need to remove this code part as well
}
怎么去掉?我以 JButton 为例.其他组件的action方法是这样的.
How can it be removed? I got the JButton for an example. Other components'action methods are like this.
推荐答案
转到 JButton 属性,选择Events"、actionPerformed 并从相邻的组合框中选择none".您的源代码已清理完毕!
Go to your JButton properties, Choose "Events", actionPerformed and choose "none" from the adjacent combobox. Your source code is cleaned!
Netbeans 的最新版本(如 7.3)不提供无"作为选项,但允许您通过删除方法名称或按 1、2 和 3 按钮来删除 actionPerformed 方法:
Recent versions of Netbeans like 7.3, do not offer "none" as an option, but allow you to delete the actionPerformed method by deleting the name of the method or by pressing 1, 2 and 3 buttons:
这篇关于如何删除 NetBeans 中的 actionPerformed 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!