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)
Related
I am currently using a library for "Notify My Android". The library is using an outdated URL so i tried to change it. I attached the source file and now I can edit the code. Before attaching the source file it just said "compiled code". But when i save it it does not seem to save the changes. It is still using the old URL. Also the change I made is underlined in blue. I hope somebody knows how to make the .jar to accept my changes.
Thanks in advance
it's highly discouraged to modify jars you depend on simply because if you ever want to upgrade versions you'd need to modify the new jar you are looking for.
In those situations you have these options:
if it is an open source project, contribute to the project and correct the URL
try and set the property from your code (this may not be possible in certain situations)
try and extend the class you're trying to use and set the URL on the property you need (like the previous one, it may not be possible to do this)
this should be your last resource: create your own project (from the original jar), make the changes you require, package it up and add it to you app.
I know I can change the L&F before startup using my app.conf file, but I would prefer to avoid that since Netbeans fails to have individual app.conf files for each individual RCP application, and I have a few that will NOT use thte target Look And Feel.
I can do this:
LookAndFeel hifi = new HiFiLookAndFeel();
UIManager.setLookAndFeel(hifi);
SwingUtilities.updateComponentTreeUI(this);
But that only updates the current component, not the toolbars, windows etc. Is there another way to solve my dilemma WITHOUT having to swap my app.conf files on each build?
I woul like to set the look and feel and have the entire application change, but NOT modify my app.conf file.
I have found it.
Generate a new ModuleInstall class, under the New->Other->Module Development->Installer/Activator menu.
It will register that class to be run during startup (specifically the Restored() method).
Put your LookAndFeel altering code in that method and you are good to go.
NOTE: This was done with Netbeans 7.4
Instead of using SwingUtilities.updateComponentTreeUI(this); Replace this with a reference to the top-level component you want to update (such as the JFrame of your application). Repeat as necessary for any other top-level components in your application (i.e. if you have multiple JFrames in use)
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.
There are plenty of tutorials out there on how to copy files to the clipboard using the SWT API. However, I've never seen an explanation of how to cut files to the clipboard. What I'm trying to do is write a simple file manager in Java where you can select a file and press Ctrl+X, and when you press Ctrl+V in the native file manager, the files are moved (not copied) from their original location to the destination. Does the SWT API actually support this, or is some lower-level API required to get this done?
Check out this image sample. Note that there is a FileTransfer class instead of ImageTranfer class which you can use instead.
Concerning CUT operation:
To do this, you must manually erase the data once it is copied to the clipboard. Java provides no implementation of a cut operation.. This is with AWT/Swing but I am pretty sure it's the same thing with SWT. You can remove it after successful clipboard copy or successful paste...your choice.
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.