Java Reference
In-Depth Information
Table 10.2 Many of the properties found in the Properties Inspector are used to control the layout
of the containers and their components. (continued)
Property
Effect
Determines if and how the component expands to fill its container
fill
Controls the alignment of the component within its container or cell
anchor
Allows the component to span multiple rows in a grid layout
Row Span
Allows the component to span multiple columns in a grid layout
Column Span
Specifies the smallest allowable size for the component
Minimum Size
Specifies the most appropriate size for the component
Preferred Size
Specifies the largest possible size for the component
Maximum Size
10.4.1
Spanning rows and columns
If you're familiar with building tables in HTML , then you have a pretty good idea
of how you can use the Row Span and Column Span properties to structure your lay-
out. Unless you're building a tic-tac-toe game, you'll almost certainly have to use
these properties to achieve the layout you desire. The Row Span property allows a
component to occupy multiple adjacent rows. Likewise, the Column Span property
causes a component to stretch itself across several columns.
These properties are set to initial values when you place your components in
grid layout, and IDEA tries to replicate your XY Layout as best it can within a grid.
You can edit the properties in the Properties Inspector to gain more fine-grained
control over the GUI you're building.
To illustrate the point, figure 10.6 shows a variation on the ACME GUI . In this
example, the JC omboBoxes' Column Span property has been changed from 2 to 1,
and those components have been moved one cell to the right.
10.4.2
Setting an anchor point (cell alignment)
When a component is placed into a layout cell, its position within that cell is
determined by its anchor property. anchor can be set to any of the eight compass
directions or to center . Figure 10.7 shows a JL abel positioned in each cell of a 3x3
grid layout, with a different anchor point for each. It's important to recognize
that the anchor controls the placement of the component inside its cell, not its
position in the overall container.
 
 
 
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search