|
|
Complex layouts
Complex layouts in Java can usually
be achieved by 'nesting' Panel objects within one
another.
Note the following:
- Panel objects are invisible, and exist only to
contain other objects
- Each Panel can have a different layout manager
- Often some trial and error is required to achieve
the desired effect
The example below shows how to
achieve a more complex layout than is offered by the
standard layout managers. It uses a two-layer structure.
The overall layout is provided by a Panel with a border
layout. The Panel has no 'real' (user-accessible)
objects, but contains two other Panels. These in turn
contain the objects that the user sees.
An alternative approach is to use
the 'grid bag' layout.
User interface design tools are
useful for designing complex layouts; they quickly show
how the display will appear without compiling the
program. This allows the programmer to make changes to
the layout structure and see the effect immediately.
|
|