• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable's Column Problem

 
Ali Hassaan
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
all ranchers
I have a problem in JTable, I need a table of several columns with different width of each column,i have came to know that it can be done with AbstractColumnModel class but i dont know how.
It will be so helpfull if someone can send me some code for assistance...
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:
tableName.setAutoResizeMode(JTable.AUTO_RESIZE_OFF)
tableName.getColumnModel().getColumn(column number).setPreferredWidth(some width)
 
Brian Snyder
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow. This was so simple and was drining me crazy!!!
Thanks Paul.
 
Mark Spritzler
ranger
Sheriff
Posts: 17290
9
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow. This was so simple and was drining me crazy!!!

Welcome to Java, If it isn't easy, then you must not be doing it right. Meaning if it is taking you many lines of code, there must be a class that makes this much easier.
well it "drives", not "drines" me crazy all the time.
Mark
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!