Features
ExplicitLayout is a constraints based layout manager that implements the
java.awt.LayoutManager2 interface. It can be used to layout any
container that extends java.awt.Container.
ExplicitLayout provides the following features:
Specify a component's location relative to:
- An absolute position
- The edges of the container (respecting the container insets)
- A fraction of the width or height of the container
- The edges of another component
- A fraction of the width or height of another component
- The edges of a group of components
- A row and column of a grid
- and more ...
Specify the location of any point on a component, not just
the top left corner. This facilitates aligning component's left, center, right,
top, middle or bottom.
Specify a component's size based on:
- An absolute size
- The preferred, minimum or maximum size of a component
or components in a group
- The size of the container (respecting the container insets)
- A fraction of the size of the container
- The size of another component or group
- A fraction of the size of another component or group
- The space between two components
- The space to the edge of the container
- A grid cell size
- and more ...
Define whether a component's width or height is set to
zero when the component is not visible. This provides some control over whether the
layout is rearranged to fill the space left by an invisible component.
Modify layout constraints at runtime based on,
for example, component visibility.
ExplicitLayout can be used alongside other layout managers by nesting containers.
It enables the preferred, minimum and maximum size of the container to be
defined based on the sizes of its components.
A LayoutListener can be notified just before layout to enable switching constraints
based on container width / height ratio. This takes care of situations when it is difficult
to define a single layout for a container that could be very wide and very tall.
Specify a component's location relative to a point on an ellipse or line.
These features improve the ability to lay out less rectangular GUI's
(e.g. with non-rectangular, transparent or overlapping components).
Load layout constraints from a properties file. Layout constraints can be defined in
a properties file using Java Language strings similar to those used when defining
the constraints in a class file. This allows layouts to be modified without recompiling
and allows different variant layouts to be specified for a particular container.
A different variant could be chosen depending on some state e.g. user preferences,
user skill level, locale, or container width/height ratio. This also allows a program
to modify its own layouts and store them in a file for use next time the program is run.
Load layout constraints from other sources. ExplicitLayout can
easily be extended to load constraints from other sources,
e.g. an XML file or a database.
Use the same layout definition for different containers. This can be useful when
otherwise unrelated containers have similar layouts but possibly different or even
optional components.
ExplicitLayout can easily be extended to support even more layout
characteristics and maximise code reuse.
|