开发者

How to remove actionPerformed methods in NetBeans

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
}

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


Go to your JButton properties, Choose "Events", actionPerformed and choose "none" from the adjacent combobox. Your source code is cleaned!

How to remove actionPerformed methods in NetBeans

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:

How to remove actionPerformed methods in NetBeans


If the button that the action was registered to is no longer in the form (this happened to me after I manually replaced the .form file with a previous backup) then you wont be able to do Costis Aivalis's solution. In this case you can open the .java file with another text editor and delete the event handler there.


In the latest version of netbeans click the button with the 3 periods [...] just to the right ov the combo box and a new control listing the handlers is displayed. Select the one to remove and press the [Remove] button.


Identify your .java file, then close Netbeans and edit your file directly from a text editor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜