如何在NetBeans中删除actionPerformed方法 [英] How to remove actionPerformed methods in NetBeans

查看:101
本文介绍了如何在NetBeans中删除actionPerformed方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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为例.其他组件的操作方法是这样的.

How can it be removed? I got the JButton for an example. Other components'action methods are like this.

推荐答案

转到JButton属性,依次选择事件","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方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆