Java Page Layout

Java provides 6 basic Layout Managers which automatically place components (buttons, fields, and the like) on the screen. Their intent is to support applications which can be used regardless of the screen size. The downside is that you have no real control over how your application is presented to the user.

(Uh, one the the touted benifits of Java is that the developer can only suggest how the application will be displayed. The implied corallary is that explicit control over your creation is somehow bad or evil. Give me a break.)

The "Null" Layout Manager

In order to position components using x/y values, you must first disable the Layout Manager using
Then, using the component methods setSize(), setLocation(), and setBounds(), you MUST either of a component before adding it to the container.
   MyLabel = new java.awt.Label();
   MyLabel.setText("test data");
   MyLabel.setBounds(x, y, width, height); 
The Sun references are pretty good, but the tutorials don't actually say to set the layout manager to null. Interestingly, IBM's VisualAge 1.0 used the null Layout Manager. I resisted this for some time because none of my books (or VisualAge's help) explained what this did or why this was a good idea. (There were actually no references to it at all.)

It is my opinion that using a combination of several Layout Managers will give you the best presentation.

Author: Robert Clemenzi -
URL: http:// / user / clemenzi / technical / Languages / Java / PageLayout.html