I don't even know if this title is appropriate or not, this thing is getting me mad.
I'm building a GUI using Netbeans, and i created a JPanel with some components to perform a search in some different contests. i would like to integrate this Panel into a few different JFrames instead of copy-pasting the same code in every frame.
Now, the Netbeans' GUI Builder only lets me insert components by dragging them out of the palette, so i dragged out an empty panel to the right position in the frame and i changed its initialization from
so that empty panel should magically become my SearchPanel at runtime. And this is actually happening, but no components are being painted into the SearchPanel.
If i override the Paint(Graphics g) method of my SearchPanel like this
to draw a line in the background, the line is successfully drawn at runtime, so i'm sure that the empty panel is actually changed to SearchPanel, but still i can see no components.
What am i doing wrong?
Eventually, is there a cleaner way to create (with netbeans) a custom panel (or any other swing component) and use it in many different frames, dialogs, panels etc... in the same project?