Java Reference
In-Depth Information
example, if one element is twice as big as elements below it, the designer causes
the larger component to span two columns.
To apply a layout to all the components in the design area, you don't
need to select them. Clicking one of the layout buttons applies the layout
to all of them.
TIP
Nesting components to control the layout
Although the capabilities of the grid layout are good enough for simple inter-
faces, you'll find that with any complexity, you'll need more control over your lay-
out options. To gain more control, subdivide your interface into several smaller
panels, nesting them together to form complex arrangements. Use the grid lay-
out of the topmost container to position your smaller panels. To group compo-
nents, select all of the components that will make up your group, and then select
a layout from the toolbar.
Creating the top-level container
Each layout you design must ultimately be part of a single container element that
will eventually be placed into your application either as part of a larger interface
or as the root content pane of a JW indow or JF rame. The top node of your com-
ponent tree is this root element, and when you use the grid layout buttons, it
defaults to a JP anel. The component toolbar also contains buttons for JS croll-
Pane, JT abbedPane, and JS plitPane, all of which can also be used as root-level ele-
ments. All the components in your layout must be placed as children of a top-
level container. Typically, the top-level container is bound to your form class and
becomes the content pane of the JF rame displaying your application interface.
The most basic and common type of container is the JP anel. It's an empty
panel that you can use to group any number of components, including other
JP anels. You assign it whatever layout is appropriate for the components it holds.
You can nest several JP anels together to create more complex interfaces.
The JS crollPane is a simple extension of the JP anel that automatically adds
scrollbars to itself when required to view its contents. You can use a JS crollPane
just like a JP anel: create it, arrange your items into it, and assign a layout.
The JS plitPane component creates a two-part container with either top and
bottom or left and right sections divided by a resizable splitter bar. Each half of
the JS plitPane is independent of the other and is its own container. Generally, you
should add a JP anel to each side to hold any controls you need to place into it.
 
 
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search