![]() |
The Java Developers Almanac 1.4 |
|
e917. Setting the Width of a Column in a JTable ComponentBy default, the column widths of all columns are equal. In order for column width adjustments to be made,autoResizeMode must be
disabled.
int rows = 3;
int cols = 3;
JTable table = new JTable(rows, cols);
// Disable auto resizing
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
// Set the first visible column to 100 pixels wide
int vColIndex = 0;
TableColumn col = table.getColumnModel().getColumn(vColIndex);
int width = 100;
col.setPreferredWidth(width);
e916. Enumerating the Columns in a JTable Component e918. Setting the Column Resize Mode of a JTable Component e919. Locking the Width of a Column in a JTable Component e920. Appending a Column to a JTable Component e921. Inserting a Column in a JTable Component e922. Removing a Column from a JTable Component e923. Moving a Column in a JTable Component e924. Allowing the User to Move a Column in a JTable Component e925. Allowing the User to Resize a Column in a JTable Component
© 2002 Addison-Wesley. |