• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Auto-Resize JTable columns based on content

 
Jayes Herryl
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I try to make a JTable adjust its column widths based on the content of the column when the table is initialized.

Apparently the setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS) does not help. Is there a way to make the table smart enough to shrink the widths on columns with more room, and expand those with more contents in the grids?

Any advice is much appreciated!
 
Maneesh Godbole
Saloon Keeper
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yuo could also check out Rob Camick's blog entry Table Column Adjuster or my Spring Table posted on another forum.
 
Maneesh Godbole
Saloon Keeper
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The SpringTable is a neat trick.
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic