I've designed my program in both null layout and the free design layout, however, when I compiler my program and run it with the null layout the window gets resized (Despite my original size, and specifying the default size, minimum, maximum etc) and the buttons are not visible anymore. However, when I compile and run my program in free design layout, the size is perfect and it works great, but my components get screwed up when I perform all sorts of operations (example : making a component visible, setting the text, etc). Is there any fix to this? I believe this is a netbeans bug but I can't tell. Please help this is a disaster. I'm using Netbeans 7.0.1
Asked
Active
Viewed 1,339 times
-1
-
3Read the Swing tutorial on Layout Managers and mix and match layout managers as required. You are not forced to use a single layout manager. – camickr Dec 29 '11 at 20:34
-
Netbean's graphical GUI builder can only get you so far. Some times it's better to get your hands dirty and do it yourself. – unholysampler Dec 29 '11 at 20:39
2 Answers
4
Is there any fix to this?
Yes, use a layout manager. Using a null layout is almost never the way to go.

mre
- 43,520
- 33
- 120
- 170
-
Which one? I mentioned the free design screws up my program irreversibly. – Bugster Dec 29 '11 at 20:01
-
I'm a fan of GridBagLayout for precise layouts. Sometimes takes some creative partitioning/sizes, but you can get it just right and it'll stick with resizing (within reason). – Brian Knoblauch Dec 29 '11 at 20:20
-
*"Which one?"* Wrong thinking. Combine them as needed in a [nested layout](http://stackoverflow.com/questions/5621338/about-swing-and-jtable/5630271#5630271). – Andrew Thompson Dec 30 '11 at 00:58
1
If you need to rearrange the components or change labels at runtime, the 'free design' is probably not the way to go. Its not designed for this, and it really has nothing to do with netbeans. You will need to understand how to use the appropriate layout managers to make it do what you want.
In addition to the standard layout managers, you might also want to look at Mig Layout.
IIRC, netbeans also offers an XY layout for absolute positioning. This is only a bit better than null layout though, because your UI will look bad once it hits another system, but if you don't care about that then that might be the right answer for you.

trashgod
- 203,806
- 29
- 246
- 1,045

BillRobertson42
- 12,602
- 4
- 40
- 57