PDA

View Full Version : Java - Swing - Layout Managers - Which one do you like?




toddburch
Mar 23, 2007, 07:26 AM
I'm getting into the "swing" of user interfaces (sorry...;)) and I'm wondering what Layout manager(s) you prefer to use? I've used the FlowLayout the most, but I don't like it so much, as controls will jump around when resizing the dialog boxes.

Thanks, Todd



therevolution
Mar 23, 2007, 07:51 AM
For anything other than a really trivial layout, I often use TableLayout (https://tablelayout.dev.java.net/). It has a little bit of a learning curve, but it's very flexible.

toddburch
Mar 23, 2007, 08:19 AM
After seeing that your preferred layout is a Java add-on, (which I didn't realize might exist), I got to thinking about this concept some more, and started wondering about the existence of a WYSIWYG editor for Java GUIs.

A quick search found SpringLayout (part of Java itself). I think I'll give it a go. :)

(EDIT - it looks like this will solve one of my bigger pet peeves, in that TextAreas don't usually grow when the window is made larger. Using this layout manager, they will. WOO-HOO!)

therevolution
Mar 23, 2007, 11:24 AM
After seeing that your preferred layout is a Java add-on, (which I didn't realize might exist), I got to thinking about this concept some more, and started wondering about the existence of a WYSIWYG editor for Java GUIs.

A quick search found SpringLayout (part of Java itself). I think I'll give it a go. :)
Yes, SpringLayout was designed for WYSIWYG editors. I've tried messing around with it and it seems pretty good. I like that it's human-readable/writable as well. Whichever layout fits your needs is the layout you should use.

FWIW, last I heard, TableLayout was moving towards being included as a standard Java library. But don't let its current non-inclusion stop you from checking it out if you're interested. It's completely free (as in speech as well as in beer) to use however you want.

(EDIT - it looks like this will solve one of my bigger pet peeves, in that TextAreas don't usually grow when the window is made larger. Using this layout manager, they will. WOO-HOO!)

Most layout managers will do this if you use them correctly. ;)