wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes JTable and Horizontal Scroll Bar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable and Horizontal Scroll Bar" Watch "JTable and Horizontal Scroll Bar" New topic
Author

JTable and Horizontal Scroll Bar

Michael Hildner
Ranch Hand

Joined: Oct 13, 2000
Posts: 297
I have a JTable with many columns, so many that the column headers are too small. I'm trying to figure out how to set a minimum size for the headers and have the user scroll horizontally to see all the fields.
I have the table in a JScrollPane, wrote some code to set minimum column size, but it doesn't seem to work - vertical scroll bar shows up when it should, but not the horizontal scroll bar, so column headers are still small.
I've looked around, but couldn't find code to scroll the table horizontally. Any ideas?
Thanks in advance,
Michael
eric moon
Ranch Hand

Joined: Nov 26, 2000
Posts: 133
I've always had to set minimum, maximum and preferred size to convince Swing not to squeeze everything in, even in a scrollPane.
Does that work for you? If you figure out which ones you really have to set, let me know! But setting minimum doesn't seem to do it.
HTH
e

<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>"Those who cast the votes decide nothing. Those who count the<BR>votes decide<BR>everything." <BR> -Joseph Stalin<HR></BLOCKQUOTE>
Michael Hildner
Ranch Hand

Joined: Oct 13, 2000
Posts: 297
This seems to work OK:
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
All headers are the same size. It's a little wierd because the colums don't expand to fill the entire scroll pane area if there are just a couple columns, but for tables with many columns, a horizontal scroll bar shows up.
I'm going to play around and see if I can't write some code that sizes individual colums to be just big enough to fit the column name.
Thanks for the info,
Michael
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable and Horizontal Scroll Bar
 
Similar Threads
JTable Horizontal Scrolling Probs
JTable Help
JScrollPane, JTable
problem in setting the column width of JTable
How to gray out one particular row in JTable