This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell 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: 10425
    
    8

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: 4571
    
    5

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: 10425
    
    8

The SpringTable is a neat trick.
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Auto-Resize JTable columns based on content