Expand windows vertically as content is added.

I am using NetBeans to create a JFrame based application (in a window). There are a few JPanel's in there which were created with the visual designer such that when the user resizes the window they will resize with it. One of the JPanels are initially empty because content is dynamically added and removed from it for something. What I would like to happen is that when the panel expands beyond the extent of the window, it should expand the window as well. Currently if the panel gets full and expands it will push the rest of the windows content down but the window itself will not expand.

Is this fixable, or is there something fundamental which is not going to allow me to do this?

I value any input, thank you :-)

[739 byte] By [nippysaurusa] at [2007-11-27 9:08:00]
# 1

in your "addobjecttopanel" method, you can do something like:

frame.setHeight(panel1.getHeight()+panel2.getHeight()+...+paneln.getHeight());

but it's not a good idea since if there are two many objects in the panels, frame will be too high for the screen height

what you should do is take a look at JScrollPane class

calvino_inda at 2007-7-12 21:45:27 > top of Java-index,Java Essentials,Java Programming...
# 2
Yes I have pondered that. You see there are only a handfull of items which can be added, at the moment it is limited to two, so going off the screen is not much of an issue. Although for now a scrollpane will have to do the job hey :-)
nippysaurusa at 2007-7-12 21:45:27 > top of Java-index,Java Essentials,Java Programming...