GoLayout

The GoLayout Applet

This applet provides a simple means by which to test out the GoLayout class and experiment with different format strings. A few standard layouts are provided and after choosing an existing example it can be modified to get a feel for the syntax.

The first step in using this applet is choosing an existing layout to experiment with. You can choose to start with an empty layout but it's probably best to start with one of the built in examples at first. These examples are all explained in the class documentation here.

Having picked the layout, the Show button can be used to open a new window containing a set of components laid out in accordance with the format string. Once the window is open, this button can be used to reset the layout back to its original state. Note that if you wish to change the format string itself then any existing window must be closed and the Show button must pressed again before any changes will be honoured.

The Edge size can be changed to modify the width and height of the notional edges which divide the components and surround the layout itself. This value should be given in the form <width>x<height> (press RETURN to accept the new value).

Once a layout has been shown, the applet will display information about the currently chosen component within the layout (highlighted in red). You can navigate through the components using the Next and Prev buttons or just click on a component shown in the window. The component's index and current dimensions are shown between the navigation buttons and the various attributes of the layout cell in which it is contained are shown below and can be edited. Note that any changes to the layout attributes, such as modifying the cell weight, will not be reflected in the format string.

The Weight value controls how much weight the current cell has with respect to the usage of any spare space within the layout. The larger the value, the more aggressively this cell will attempt to claim any available spare space, whereas a weight of zero means that the cell will not attempt to fill any spare space, even if it would otherwise be unused. Note that just because a cell has a high weighting it may not result in it being given more space (it depends on the order in which rows are processed).

The Alignment value controls how the current cell's component is vertically aligned. Because GoLayout is designed for primarily horizontally flowing layouts, this feature gives some useful control over vertical alignment which would otherwise be tricky to achieve. There is no equivalent horizontal alignment modifier as this is achieved using the format string.

The Size value can be used to force a fixed size for the current cell. If either the width or height of a cell is set to anything other than -1 then GoLayout will not change this dimension at any stage during the layout. If this size is too small for the component within that cell then it may result in it being displayed incorrectly. The use of a fixed size for cells is only suitable if the component it contains has very well defined size requirements.

The Active checkbox defines whether or not the current Cell is active within the layout. An inactive cell will not seek to take up any space within a layout, but that doesn't mean that it won't be given any space (this depends on the layout of the cells around it).

The Min and Pref values control the size preferences of the components within the layout cells. By changing these values you can mimic the effect of having many different types of component in the layout. If the overall space available for the layout is larger than its preferred size, then every component within the layout should be given (at least) its preferred size. No component will ever be made smaller than its minimum size, even if this means that the components do not fit within their container. This situation should be considered a serious problem and not something which end users should be exposed to.


While I believe that I have covered most of the important requirements of a layout manager for real world situations I would be very interested in hearing from anyone who thinks they have found a layout problem which can be easily solved using the standard AWT layout managers but which is impossible, or at least unusually difficult, to achieve using the GoLayout class. You can contact me via .

.