• Post Reply Bookmark Topic Watch Topic
  • New Topic

fixed column width in JTable  RSS feed

 
mark I thomas
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a JTable in a JScrollPane. I found the Table automatically fits the ScrollPane. For example, if the table has 3 columns then each column appear to be very wide. If it has 10 column then each column is narrow. How do I specify the exact width of each column of the JTable ?

I tried

table.getColumnModel().getColumn(col_index).setWidth(xxx);

But it seems to have no impact. The Table automatically fits the ScrollPane.
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Rob Spoor
Sheriff
Posts: 21094
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set the minimum and maximum widths to be equal.
 
mark I thomas
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!