This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Auto-Resize JTable columns based on content Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Auto-Resize JTable columns based on content" Watch "Auto-Resize JTable columns based on content" New topic
Author

Auto-Resize JTable columns based on content

Jayes Herryl
Greenhorn

Joined: Jun 09, 2006
Posts: 7
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

Joined: Jul 26, 2007
Posts: 10744
    
    9

This is what you need.
http://jroller.com/santhosh/entry/packing_jtable_columns

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4986
    
    8

Yuo could also check out Rob Camick's blog entry Table Column Adjuster or my Spring Table posted on another forum.


luck, db
There are no new questions, but there may be new answers.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10744
    
    9

The SpringTable is a neat trick.
Thanks
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Auto-Resize JTable columns based on content
 
It's not a secret anymore!