• 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

NX: width proportion in DefaultTableModel

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, everyone,
I use DefaultTableModel as the TableModel of JTable. I
rearrange the TableColumn's display width according to the
field's length, but after I use the DefaultTableModel's
setDataVector() method, all the columns become equal average
width. How could I keep the column's width proportion with DefaultTableModel?
Regards,
Davidd.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Davidd
Sorry, I am not answering your question, but just something for you to think about: I didn't bother setting the column sizes, and I was not penalized for it.
Regards, Andrew
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Column widths are controlled by the TableColumnModel, not the TableModel. It's probably more trouble than it's worth to deal with this, IMO, as the relationship between the TableModel and TableColumnModel APIs is needlessly convoluted. E.g. you can set column titles in either one. It's easy to do something with the TableModel that screws up the titles you set with TableColumnModel, or vice versa. Since nothing in TableColumnModel is really required for the assignment, you'll probably live longer if you don't use it.
 
Davidd Smith
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Andrew and Jim,
Thank you for your reply, I will follow you advice, it saves me a lot of time.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic