tags:

views:

14

answers:

1

After building the application GUI, I realised it was a little bit too complex and I could reuse some of the Swing components. The result is a complex class with many anidated JPanels.

My question is: does Netbeans provide a way to split a JPanel and its children components into a different class?

If I do it by hand, will the GUI designer still work?

Thanks!

+1  A: 

What you want to do is make your components beans and import them in the NetBeans palette. That way the GUI designer will indeed work. All you need is to provide a public, no-argument constructor and have the class implement Serializable (which they should already if they are Swing components). Getters and setters are optional, but you need them if you want to be able to set their properties using the properties window.

See this tutorial for an example of making a bean and adding it to the palette.

JRL