views:

230

answers:

2

Hi, this title may not best describe my problem. I'm using Netbean GUI builder to create a JFrame and several JPanels. I create each JPanel in a seperate class, then I drag the JPanel class to JFrame. The problem is after dragging the JPanel to JFrame, if I add components to JPanel, it does not show the additional components in the JPanel contained in JFrame. I tried "clean and build" but the new component still not showing in JFrame -> JPanel.

+1  A: 

I know what you mean; Matisse (NetBeans' GUI editor) lets you drag and drop self-assembled Containers (e.g. JPanels) into other Containers (e.g. JFrames), but any subsequent changes in the former will not be reflected in the latter. As far as I know, that's just the way it works, unfortunately.

It's one of the reasons I think Matisse can only be used for quick prototyping and toying around. For anything serious, the GUI must be hand-coded.

Joonas Pulakka
A: 

Matisse keeps a cached copy of any component you add to the palette. So, subsequent changes are not automatically picked up. To pick up the changes:

  • save and close your JFrame source
  • Make sure the JPanel component is compiled.
  • Click Tools > Palette > Swing/AWT Components
  • Right click on the tree and choose Refresh
  • Open your JFrame component. It should now be showing the updated components
Devon_C_Miller
Unfortunately, this method does not work on my NB6.8 (Mac)... Which NB did you test this method? Thanks!
Patrick
NB6.8 on Windows XP. But, it's also worked for me on Ubuntu. Be sure to perform a full build otherwise you can wind up with one .class file in build/classes and a different one in the jar. Matisse will always use the one in the jar. Even if the one in build/classes is newer.
Devon_C_Miller