Introduction
Containers Layouts Widgets Miscellaneous

Layouts

A layout (or layout manager) is a way of arranging widgets inside a container. This means that you can make a button or a listbox and just add them to a panel, and let the manager figure out what are the sizes, or their exact x's and y's.

It is possible to have multiple layouts in a single frame. To do this, simply add panels that have different layouts to a frame. You can then control how you want to arrange the components in each of those panels. This is called nesting or nested panels.

Not all Layout Managers in Java have been implemented in gui.irc. Most of the common ones are available.

To set the layout manager, simply add the layout property in a panel() or a boxpanel().

In Java, it is necessary to use the full name of the layout, such as FlowLayout. But for gui.irc, the layouts can be specified simply as flow, border, grid, or box. The names are also not case-sensitive. For example:

$p = panel($frame, 'layout=grid 3 3');

For null layout or absolute positioning, there is no need to specify the 'layout' property because it is the DEFAULT layout of panels in gui.irc.

Adding widgets to a container

When you add widgets to a container, the arguments you specify to the add() command depend on the layout manager that the container is using. For example, BorderLayout requires that you specify the area to which the component should be added, using code like this:

add($frame, $component, "area=NORTH");

The section for each layout manager has details on what, if any, arguments you need to specify when adding the components.

For more information on Java Swing's layout managers, go to this link. Even if you don't know Java, you'll understand a bit about how actual layout managers work.

- End of page -
Hosted by www.Geocities.ws

1