开发者

remove component from initComponent()

i am using netBeans editor to create desktop application , i did something wrong that generate three line of code in the initComponent() method related to connection with database. Then i removed the lines by opening the .java file in txt editor , but one of them keep coming back when i do anything with netBeans editor , So i want to delete this line from the netbeans itself . this is the line

historyList = java.beans.Beans.isDes开发者_运维问答ignTime() ? java.util.Collections.emptyList() : ((javax.persistence.Query)null).getResultList();

and this is its declaration

private java.util.List<idetect.History> historyList;


Use the Inspector to find the query component and delete it

Window->Navigating->Inspector menu in Netbeans IDE 7.0.1


I think the simplest way to edit the automatically generated code is to do the following;

If you go to the Design panel of your class in Netbeans (where you can see the constructed GUI) then all of the elements you have added will be in the Navigator Pane, which is usually located in the bottom left. If you can't see the Navigator pane then ctrl+7 brings it up. Find the element you wish to remove in the list, right click and click Refactor > Safely Delete.

Personally if I need to write a GUI in Netbeans I use it to generate the boring stuff, and then paste the generated code into a different editor to write my actions.


The java source is regenerated automatically from the matching .form file. You need to delete the component either from the GUI editor itself or from the form file(which is not visible in NetBeans).

When you've opened a GUI form in NetBeans its components are visible in a tree in the Inspector tab in the lower left part of your screen. You can select the component you want to delete there, right click and select "Delete".


Easiest Solution: Open the .java-file in your project-directory containing your "initComponent"-Method with another text-editing Program (e.g. notepad++) and delete the lines you want to remove. It worked out for me.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜