ted holden said:
One other thing I notice and which you might want to comment on is the
following. There seem to be several layout models in Java, and the only
one which seems to work or function at all, at least in Eclipse, is the
null layout. The others seem to be intended for use by masochists.
Further, I seem to be able to avoid all such problems by simply using swing
container classes, particularly splitters, in lieue of trying to fool
around with the various layouts. Am I missing anything?
Yes, you absolutely are missing something. Layout managers are there to
solve a very important and difficult problem. Though it's possible to
properly solve this problem using a null LayoutManager, the chances that
you're doing so are approximately nil. For example:
1. What happens when someone resizes your application window? If you
don't currently allow the user to resize your application window,
wouldn't it be nice if they could?
2. How certain are you that your layout will look presentable on a
different operating system (or Swing look and feel) than the one you
test one, where components may look completely different?
3. How certain are you that you could easily internationalize your
application, replacing all the text in labels, buttons, etc. with text
in a different language that may be much longer or shorter, and still
have the application look presentable? Are you comfortable with the
"make everything too big and hope it fits" technique, or would you like
something better?
4. How certain are you that your application would even be usable by
someone with serious vision problems who has set a default font size of
24 point, and can't see the screen with anything smaller?
Layout managers, in short, are critical to writing a well-designed GUI
application in Java. They are also not much harder to use than
explicitly specifying a position and size for each component; you just
have to work at a higher level. Some of the most important are
BorderLayout and FlowLayout, but GridBagLayout (the infamously difficult
layout manager) also has its uses. Some people would prefer that I say
BoxLayout instead of FlowLayout, but I'm not one of those people.
As for the difficulties in using them, you haven't given enough
information to help very much. You mentioned that you're using a GUI
builder with Eclipse; which one? It may be that the GUI builder (like
many of them do) is making layout managers more difficult than they need
to be.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation