![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e632. Setting a Row or Column of a GridBadLayout to a Particular SizeBy default, the width of a column in a gridbag layout is set to the widest component in the component. This example demonstrates how to increase the width of the column to a particular size. The same applies to rows of a gridbag layout.See e622 Creating a GridBagLayout for an example on how to use a gridbag layout. // Sets the minimum width for column c to be w pixels wide public void setColumnMinWidth(GridBagLayout gbl, int c, int w) { int[] ws = gbl.columnWidths; if (ws == null) { ws = new int[c+1]; } else if (ws.length < c+1) { ws = new int[c+1]; System.arraycopy(gbl.columnWidths, 0, ws, 0, gbl.columnWidths.length); } ws[c] = w; gbl.columnWidths = ws; } // Sets the minimum height for row r to be h pixels high public void setRowMinHeight(GridBagLayout gbl, int r, int h) { int[] hs = gbl.rowHeights; if (hs == null) { hs = new int[r+1]; } else if (hs.length < r+1) { hs = new int[r+1]; System.arraycopy(gbl.rowHeights, 0, hs, 0, gbl.rowHeights.length); } hs[r] = h; gbl.rowHeights = hs; }
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 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 e633. Setting Gap Sizes in a GridBadLayout
© 2002 Addison-Wesley. |