java类库详细讲解
源代码在线查看: colresize.html
Setting the Column Resize Mode of a JTable Component
(Java Developers Almanac Example)
BODY CODE {font-family: Courier, Monospace; font-size: 11pt} TABLE, BODY {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt} PRE {font-family: Courier, Monospace; font-size: 10pt} H3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11pt} A.eglink {text-decoration: none} A:hover.eglink {text-decoration: underline} -->
The Java Developers Almanac 1.4
Order this book from Amazon.
Home
>
List of Packages
>
javax.swing.table
[62 examples]
>
Columns
[11 examples]
e917.
Setting the Column Resize Mode of a JTable Component
Resizing the width of a column can affect the widths of the other columns
in the table. There are several resizing modes available.
The default is AUTO_RESIZE_SUBSEQUENT_COLUMNS.
// Disable auto resizing
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
// When the width of a column is changed,
// the width of the right-most column is changed
// so that the width of the entire table does not change
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
// When the width of a column is changed,
// all columns to the right are resized so that the width
// of the entire table does not change
table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
// When the width of a column is changed,
// only the columns to the left and right of the
// margin change
table.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
// When the width of a column is changed,
// the widths of all columns are changed
// so that the width of the entire table does not change
table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
Related Examples
e914.
Converting a Column Index Between the View and Model in a JTable Component
e915.
Enumerating the Columns in a JTable Component
e916.
Setting the Width of a Column in a JTable Component
e918.
Locking the Width of a Column in a JTable Component
e919.
Appending a Column to a JTable Component
e920.
Inserting a Column in a JTable Component
e921.
Removing a Column from a JTable Component
e922.
Moving a Column in a JTable Component
e923.
Allowing the User to Move a Column in a JTable Component
e924.
Allowing the User to Resize a Column in a JTable Component
See also:
Cells
Column Heads
Editing
Events
Layout
Rows
Scrolling
Selection
Sorting
Table Model
Tool Tips
© 2002 Addison-Wesley.