![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e629. Setting the Location of a Component Within the Cell of a GridBagLayout Using AnchorsBy default, when the cell is larger than the preferred size of a component, the component is centered within the cell. You can specify other relative positions using the anchor constraint. For example, specifying an anchor ofNORTH causes the component to be
horizontally centered with the top edge of the component aligned with
the top edge of the cell. Specifying an anchor of NORTHEAST
causes the northeast corner of the component to coincide with the
northeast corner of the cell.
See e622 Creating a GridBagLayout for an example on how to use a gridbag layout with gridbag constraints. GridBagConstraints gbc = new GridBagConstraints(); // These are the nine possible anchor values gbc.anchor = GridBagConstraints.CENTER; gbc.anchor = GridBagConstraints.NORTH; gbc.anchor = GridBagConstraints.NORTHEAST; gbc.anchor = GridBagConstraints.EAST; gbc.anchor = GridBagConstraints.SOUTHEAST; gbc.anchor = GridBagConstraints.SOUTH; gbc.anchor = GridBagConstraints.SOUTHWEST; gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.NORTHWEST;
e623. Setting the Location of a Component in a GridBagLayout e624. Getting the Number of Rows and Columns of Cells in a GridBagLayout e625. Making a GridBagLayout Fill the Container e626. Setting the Stretchyness of Rows and Columns in a GridBagLayout Using Layout Weights e627. Setting the Stretchyness of Columns and Rows in a GridBagLayout Using Component Weights e628. Setting the Stretchyness of a Component Within the Cell of a GridBagLayout Using Fill e630. Setting the Space around a Component Within the Cell of the GridBagLayout Using Insets e631. Adjusting the Size of a Component in a GridBadLayout Using Internal Padding e632. Setting a Row or Column of a GridBadLayout to a Particular Size e633. Setting Gap Sizes in a GridBadLayout
© 2002 Addison-Wesley. |