• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTable and Horizontal Scroll Bar

 
Ranch Hand
Posts: 297
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Michael Hildner
Ranch Hand
Posts: 297
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic