![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e624. Getting the Number of Rows and Columns of Cells in a GridBagLayoutThe number of rows and columns in aGridBagLayout automatically
grows as needed when components are added. The current number of
rows and columns can be determined by calling
getLayoutDimensions() . However, it won't return the correct
values until the components have been laid out at least once before
the call to getLayoutDimensions() . Unless you can be sure the
components have been laid out at least once, you should explicitly
call layoutContainer() to force a layout of the components.
GridBagLayout gbl = new GridBagLayout(); container.setLayout(gbl); // Add components to container and gbl // Force the layout of components before calling getLayoutDimensions() gbl.layoutContainer(container); // Get the dimensions int[][] dim = gbl.getLayoutDimensions(); int cols = dim[0].length; int rows = dim[1].length;
e623. Setting the Location of a Component 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 e629. Setting the Location of a Component Within the Cell of a GridBagLayout Using Anchors 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. |