I am new to NetBeans IDE and I am using NetBeans GUI builder for creating my GUIs. I am creating a new file by right-clicking the package and click new and then click the new JFrame Form.
It is working fine. But I have a java file with a JFrame which I created manually by coding.
Can I import it into that GUI builder so that I can drag and drop and make the GUI? If yes How can I do that? (In eclipse we can do that by right-clicking the file and click open with windowbuilder editor.)
The Netbeans GUI builder works by generating code fully controlled by Netbeans, plus it maintains a hidden .form
file. So you can't directly import your JFrame
and make it fully customizable by the GUI Builder.
However there are things that might help.
You can modify your JFrame
by adding JPanels
designed using the GUI Builder. In Netbeans project view, select your package and create a new JPanel form, edit it, save it. Then in your JFrame
code, manually insert JPanel
instances where you need it.
Another trick:
JFrame
and create a JPanel
file with
it, with a public no-argument constructor.JPanel
component available in the GUI builder palette, in the relevant CategoryJPanel
component in the JFrame
formNote that the JPanel will not be editable itself, you can just manipulate it as a block in the GUI builder.
NOTE: in my experience, after doing Tools/Add to palette, it's sometimes needed to close/reload a form file to have the added component actually appear in the GUI builder palette.