Alright, sparked from a comment made in another topic, I'm going to start this up to see what everyone's opinion is.
I've used about 5 different GUI frameworks, and they all had these sort of "Standard Layout Managers". Of course, they all functioned in their own way for when you were programming them, had their own pro's and con's, but all in all they weren't even really that standard. I'll list a few layout managers I've used, and compare why I like/dislike them.
FlowLayout - I've found this layout to be pretty standard. You can align it left, right, centre, and leading. I rarely use this except usually when managing simple panels or being lazy, because when resizing typically the results aren't visually pleasing.
GridLayout - Ok, in Java this layout sucks pretty hard, and I try to avoid it. Essentially you tell it how big of a grid you want, it makes it, you put stuff into it sequentially, and it goes in left to right, top to bottom, and you can tweak a few things, but not many. You cannot span multiple rows/columns, you cannot add directly to a cell, you can't even define a different sized cell from the rest. Pretty much only useful when you want a static grid (not very often I find).
BorderLayout - One of the other standards I find fairly commonly. Splits your panel into 5 pieces, north, east, south, west, centre. You tell the components where you want them. It's fairly good as a top level application layout I find, good to have your title and top controls in the north panel, and buttons or whatever in the south panel, relevant information in east and west, and then main navigation in the centre.
GridBagLayout - More like douche bag layout. Ok, not really, but here's the run down. Essentially it's a grid layout on steroids, you can do anything and everything you could ever want to do with a grid and more. Spans, borders, set sizes, resize rules, internal/external padding, etc. etc.
The problem? It's designed to be used with a visual GUI designer. Trying to deal with it by hand is probably the most frustrating thing I've ever had to do. I tried to write a wrapper around it and got frustrated pretty quickly. Avoid it.
Null Layout - Blah, absolute positioning. Unless your window is not resizable, don't do it.
Those are the only one's I've used in the standard Java API. As a contrast I'll compare a few that appear in QT Jambi that I've used (yes the framework is discontinued, but that's just because the C++ variant is becoming incredibly stable for cross platform development).
QGridLayout - If god were to design a layout, this would be it. You can tell it how big you want it. You can also let it figure out for you how big it is based on what you put in it. You can span columns if you want. You can change row sizes, column sizes, cell sizes, almost everything Gridbag Layout can do. The difference is this layout is so straight forward, so easy to use that you can essentially use it as a basis for anything you want. Incredibly straight forward to use.
HBoxLayout and VBoxLayout - Make your own rows and Columns! Easy peasy, make layout, fill layout, done! But they have so many more options too. Stretch them, shrink them, do what you want. They are very flexible!
FormLayout - Making a form? Perfect! This is a constrained GridLayout that makes it easy to create forms. It has two columns, left column you put your labels, right column has controls, and things end up looking good. Huge time saver if you're making a form heavy app.
Now, those are just one's that I've dealt with. I've dealt with a few more, but I think I've done enough typing here. Let me hear about your trials and tribulations with layout managers. What do you like/dislike about the ones you use? What would you like to see?
GUI Layout Managers
Page 1 of 1
The Good, the Bad, and the Impossible
2 Replies - 2736 Views - Last Post: 07 March 2010 - 12:15 PM
Replies To: GUI Layout Managers
Page 1 of 1