Skip to main content

Create separate files for each JPanel

2 replies [Last post]
Joined: 2007-06-14

I'm new to NetBeans and trying to create a nice GUI with GUIBuilder Matisse.
One of the first things I want to do is to create separate files for each JPanel so that the code is easier to read. How can I do that?
What I can do is to design all panels in individual files and then add them together to a frame with a hand made java file with the base Jframe, but I rather use NetBeans Matisse and create the Jframe and then add my jpanels from there own java files.

I know that I can do this by creating a library jar and adding it the to the Beans palatte but that

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-09-11

So, what you want is to have all your panels in separate source files? U can try doing this:

Use the new file... wizard to create a JPanel form, which u can design using Matisse like a normal JFrame. After which, to put that panel in ur frame, under custom creation code for the panel in ur JFrame:

//assume ur custom form class is called CustomFrame in
panel = new CustomFrame ();

I assume u'll have your own methods for passing objects between ur panel and frame, because since the panel is no longer an inner class of the frame, it can't access whatever objects you have in the frame, outside the panel.

Joined: 2006-09-11

*Correction. It shld go something like
//assume your custom panel is called CustomPanel

panel = new CustomPanel ();