• 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 column widths

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having trouble setting the widths of the columns of my table. There's only 2 of them and they're coming out so wide they're crowding out stuff on the other sides.

What I've tried thus far:
1) set the widths in my own tableColumn model from an object[] that has the widths.


2) After the table is built, get the columns and set their widths like so:


3) set the size of the entire table like this:


I'm wondering if my layout manager is over-riding the table's choices. I'm using GridBagLayout and have set the gridwidth to 1 cell, weightx to 0, and the fill to Vertical. So it shouldn't be getting wider...


Any suggestions?

ms
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mike,

Any suggestions?


Yes, try method "setAutoResizeMode()" in class JTable.

Good Luck,
Avi.
reply
    Bookmark Topic Watch Topic
  • New Topic