Absolute layout


As was seen with the previous examples, many, if not most, GUIs can be laid out using the flexible layout managers. Occasionally, though, you may simply want to lay out your components in fixed positions and sizes.

Although we do not recommend constructing user-interfaces in this manner, this Magercise nontheless asks you to lay out a number of components this way and introduces you to the tools needed to align them neatly on the screen.

Note, that the tutorial that comes with VisualAge for Java goes into more details about how to use these tools.

An OS/2 C version of this Magercise exists in this directory. Note that the behavior of the C program may not be the same as the Magercise -- it is presented here for comparision against the Java application you will write in this Magercise. One of the major differences is that the C version does not support layout managers, so resizing a window will not resize the contents of that window.

Work Location

Perform all work for this magercise in VisualAge project MageLang Magercises, package magercises.xylayout.

If this project does not appear in your Workspace add it from the repository (if it exists there) or create a new project using this name.

Tasks

Perform the following tasks:

  1. Create a new applet called XYLayout, and add a Button, a Label and a TextField. Do not worry about their placement for the time being.

  2. Make the components all the same width and height.

  3. Now left align the components.

  4. Finally, space them out vertically.

The task numbers above are linked to the step-by-step help page. Also available is a complete solution to the problem, and expected behavior, to demonstrate it.

Copyright © 1996-1997 MageLang Institute. All Rights Reserved.