File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 9990
    
    7

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: 4522
    
    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: 9990
    
    7

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
 
Similar Threads
JScrollPane, JTable
jtable
JTable setMinimumSize problem
What listener for JTable header column size change
JTable