My program fills a panel with checkboxes dynamically and I want the panel to stretch accordingly to the amount of content,
this works fine as long as I keep the window at the same size at runtime as I do when I'm working in NetBeans. However, if I
try to maximize the window, the panel suddenly gets greedy and takes up a lot of extra space beneath the checkboxes, without
actually putting anything else in there.
Any suggestions as to how I could solve this? I've been using a BoxLayout with the vertical resizable on the aforementioned panel.
Thats what maximizing does, it maximizes the vertical and horizontal areas.
For more help create a SSCCE that demonstrates the incorrect behaviour.
Joined: Oct 09, 2010
Yeah, but it doesn't maximize it completely either. It just uses about 200 pixels more than it should when I maximize the window.
So there's still room for it to stretch more, which doesn't make any sense as to why it just randomly stops, but I'd rather it stopped
stretching after the panel was filled. So is there any way to decide the size of the panel without using the vertical resizable option?
Thanks for the help guys, but I just did what I asked for in the last line above :P Just added the preferredSize (height) of the given
checkboxes to a variable and adjusted the panel size to that variable, and using the BoxLayout with the page axis.
If you use layout managers correctly, you should never have to adjust a size manually.
I encourage you to post a SSCCE, as Rob already asked, so others here can study it and advise you how to improve it.
There are no new questions, but there may be new answers.
Joined: Oct 09, 2010
Of course not, but I find creating a relatively large GUI in NetBeans is a bit of a wrestle itself.
Since I'm using NetBeans to create the GUI, I'm pretty sure that creating that exact part
would've been easier manually. But I'm not familiar with using custom components in the NetBeans
GUI editor, so this will have to do for now. I might come back to it later if the schedule allows for it.