This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable column widths  RSS feed

 
Mike Southgate
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • 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
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mike,
Any suggestions?

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

Good Luck,
Avi.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!