• Post Reply Bookmark Topic Watch Topic
  • New Topic

Varaible row count in JTable

 
Mini Pilla
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am using JTable(Vector row,Vector column).
IS there a way to set the size of a columns as my rowsize is not static in each row.
It will b great if someone suggest any alternatives.
Thanx
Rajani
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To set the size of a column in a JTable you have to get the column... if you know what specific column you want to get you can just call getColumn( identifier ) on the JTable. identifier is whatever name you passed in when you constructed the column. If you don't know the column, or you want to affect all or a group of columns, you'll want to get the JTables TableColumnModel, by calling getColumnModel() on your JTable. Then you can get the column by index ( by calling getColumn( int ) ) or by iterating through an Enumeration of all the columns ( by calling getColumns() ) in the TableColumnModel.

Once you have the column you want, there are plenty of methods to change it's size. setMaxWidth( int ), setMinWidth( int ), setPreferredWidth( int ), and sizeWidthToFit().

You may want to look at JTable, TableColumnModel, and TableColumn in the API if you need additional information.

-Nate
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!