Re: Detailed GridBagLayout tutorial
Knute Johnson wrote:
....
The easiest solution is to not use a layout manager.
I was just *waiting* for someone to say that. ;-)
...I know that that
sends shudders through the cognoscenti but there are millions of C
programs out there that position their components that way.
I can see how that can work in two situations..
1) If the text size, look and feel and other UI
related matters can be pinned down to the last detail.
That may be true of your typical C program, but Java
GUI's are more *often* X-plat, Multi-PLAF, used under
(potentially) different Java versions and end user
settings (screen res., font size - etc.), any of which
can destroy the rendering of (textual) components in
an 'absolutely positioned' GUI.
...if you are writing a 'run once' dev. tool, I see no
reason to worry about any the above - for most
other Java GUI projects, they become a factor.
2) If the entire content area is something you are about
to render, pixel by pixel (e.g. rotatable 3D wire-frames
or models), but that situation is not one where there is
any point to actually setting a null layout - just override
paint()/paintComponent() and go wild!
...and I ultimately think that if the project actually needs
a PutItWhereverIDropItLayout, it only takes a few lines
of code to turn (whatever) short logic that may entail,
into a LayoutManager.
(I refuse to shudder)
Andrew T.