This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTables and JScolPanes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTables and JScolPanes" Watch "JTables and JScolPanes" New topic
Author

JTables and JScolPanes

malcolm bailey
Greenhorn

Joined: Aug 10, 2001
Posts: 22
Hi,
I have a JTable with 5 columns. I want to restrict the size of the first 4 columns (done) and have the last one expand to fit the data in it, but I want the viewable area to remain the same and a horizontal scrollbar to appear at the bottom so that I can scroll along to look at the data in the last column. The table is updated regularly by the user. Can anyone help me with this??
Ta,
Malcolm
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Set the width ( setMinimumWidth() ) on the column which you can get with table.getColumnModel().getColumn(column number). You may need to set the preferred width as well. And make sure you set resizing off table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF)
[This message has been edited by Paul Stevens (edited August 10, 2001).]
malcolm bailey
Greenhorn

Joined: Aug 10, 2001
Posts: 22
Cheers Paul,
How about dynamically resizing the last column...?
 
Don't get me started about those stupid light bulbs.
 
subject: JTables and JScolPanes