remove component from initComponent() - java

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.isDesignTime() ? 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.

Related

Extracting all string literals from a java project

There is a big Java project that contains lots of Java and JavaScript classes. We need to translate the app into a foreign language.
What we need to do is:
Right click on a class
Click on Extract Strings button
Display all strings in the file with a check-list structure in a pop-up window
Select the strings we want to save
The unselected ones will be assigned as not-string-literal in order to prevent it from appearing in the list when I try next time.
Click on Ok and the strings are stored in a messages.properties file
We are using Netbeans IDE and a plugin would be wonderful if there is any. Can you advise me on how to do this?

How to remove Query from JFrame GUI in Netebeans?

I have accidentally dragged "Query" from Java Persistence Section in Windows Palette.
Now I have hard time removing it from the source code. Below is a screen shot.
How can I restore my interface?
Open the GUI-Editor again and remove it from there (see Window/Panel: Navigator).Or open the file in any text-editor to remove it.
(Don't forget to re-load the form within NetBeans-GUI-Designer after changing code via Text-Editor)

Logo not displaying in excel

I have an excel template with a logo at the left-top and an empty table after that. I am using java to generate an output excel file based on that template with filled table data. But in the output excel the logo is not getting displayed. Instead of the logo I am getting this :
Any fixes?
Thanks in advance.
Here is a solution that could correct that issue: In the Start menu, go to All Programs, then Accessories, then 'System Tools'. From there type 'Folder Options'. In the View tab of the dialog, clear the checkbox for "Hide extensions for known file types". Select OK.
To fix the icons, try repair Office. In the control panel, go to Programs & Features, right-click Microsoft Office(YEAR)-select Change. When the wizard opens, click on the Repair options, then press Continue.

How do I create an area were files dragged into it add the URI to a list?

I am trying to create a program were the user drags a file into an area (currently a JTextArea, but can be another container) and it adds the absolute path of the file to an ArrayList. I am having trouble figuring out how to implement drag and drop of files.
so far I have tried reading some similar questions but they aren't really helping me.
(also this is targeting windows but linux/mac support is an option as well)
Have a look at oracles page about DnD. Basically you can drag everything into your program, should it be a file directly from a native browser or the JFileChooser. What you are dragging is only the path to the file. So you only have to set your JTextAreato accept drops and define how it has to "interpret" the object that was being dropped.
Here is a full blown example.

Eclipse recent files

Is there any list of recently opened files in eclipse?
If yes then is there also any shortcut for it?
Frequently I close classes in editor because there are too many of them opened. But in a few minutes I need them again. Maybe you solve this problem differently?
Thanks!
Probably your best option is to use "Quick Switch Editor" (Ctrl+E) but it displays the opened files only. There you have quick list along with filtering by starting to type first chars of file name. To make it useful, you may increase the size of opened files/windows before closing - Window->Preferences->General->Editors->Number of opened editors before closing. After you reach this threshold the oldest file open is closed in order to make room for newly open one.
The list of the files recently opened is displayed in File menu, just before the Exit menu option.
There you'll find the already open and last closed files.
If you want to use it extensively then you should probably increase the size of the items - Window->Preferences->General->Editors->Size of recently opened files list. You can quickly invoke one of last 9 filed with Alt+F,[Digit].
A drawback of third option "Open Resource" (Ctrl+Shift+R) is that the default list looks sorted, so it is not based on the most recent date of use. Also "Open Type" (Ctrl+Shift+T) has a long listing over time and you should enter part of the name to get a shorter match.
My initial comment is based on Eclipse 4.3 Kepler and is applicable to current latest Eclipse (4.5 Mars) too.
If you click on the File menu, you would see the list of recently used files. By default there are four of them. To increase the no, goto Window-> Preferences-> General -> Editors. You can set to as many as 15
If you know the class name you can use Ctrl+Shift+T (for classes) or Ctrl+Shift+R fo any other resource file. You don't have to type full name just the uppercase letters. Eclipse shows recently opened file in topmost section and other files in the lower section.
You can also use Ctrl+Q to goto last edit location.
For a complete list of shortcuts goto Help>KeyAssist. Also checkout Tips and Tricks under the same menu.
I'm using CTRL + F6.
Unfortunately it is not possible to use "regular expressions" as for CTRL + O, but I think this is what are you looking for.
You can either use the "last edit location" shortcuts on the toolbar (the yellow arrows, alt+left) if you wish to reopen a recently edited file, or use the short list of recently opened under the "File" menu (right above "exit")
I created a plugin called "RecentEditors" that shows a list of recently closed files, sorted by close time (so the last closed editor is at the top). There is also a command (and keyboard shortcut) to directly re-open the last closed editor.
You find the plugin on the Eclipse Marketplace, and GitHub.

Categories

Resources