Skip to main content

swing layout managers and the web..

Posted by eitan on June 30, 2005 at 12:31 AM PDT

so another big theme regarding the java desktop track at javaone is layout managers. looks like they're really and finally solving many of the issues that developers have had with layout management in awt/swing. indeed project matisse is receiving much attention.

the current, almost defacto layout managers in swing these days are the tablelayout derivatives, namely the most excellent jgoodies forms library. this layout manager's philosophy has beauty in its simplicity: it does away with the complication of insets or margins by simply making commonplace the use of empty cells on a grid. so cells are used to both place components and as white space. the grid is very flexible and can be customized in a number of ways. the main advantage is that the layout manager listens to its child components and their size preferences. the other is the fact that you can customize alignment, fill policy, rowspan, and colspan per cell. with these simple ideas as building blocks, developers today are layout out pains in a relatively clean and painless manner.

so here's where things get interesting. on the web there's been a strong movement to erradicate html tables as a layout management tool. today using html tables for this purpose is taboo. yet html by design does not even address the issue of layout management. xul by contrast does. it provides very specific provisions for alignment, fill, and layout management in general.

now let's think about this for a moment: what is an html table? surprisingly it's eerily similar to the jgoodies forms layout manager: it's grid based, it observes/respects its child component preferred sizing behavior, and allows for colspan and rowspan, cell alignment, etc..

so what gives? in the swing world, the same design is a wonderful thing, embraced by all. yet on the web, the very same design is shunned. this comes to show that when people talk about "good" design or "bad" design, most of the time they're just talking about "design a la mode:" whatever is in fashion today.

so the moral of this little blogpiece is: don't be swayed by temporal currents: stick to your guns, even if they happen to be unpopular "aujourd'hui." before long the currents will change again.

ps: you gotta love san francisco: i'm posting this blog entry from an irish pub with free wifi (!) and a guiness by my side.