• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

JTable's Column Problem

 
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...
 
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)
 
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.
 
ranger
Posts: 17344
11
Mac IntelliJ IDE 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!