aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: width proportion in DefaultTableModel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: width proportion in DefaultTableModel" Watch "NX: width proportion in DefaultTableModel" New topic
Author

NX: width proportion in DefaultTableModel

Davidd Smith
Ranch Hand

Joined: Jul 28, 2003
Posts: 62
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.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11278
    
  59

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


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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.


"I'm not back." - Bill Harding, Twister
Davidd Smith
Ranch Hand

Joined: Jul 28, 2003
Posts: 62
Hi, Andrew and Jim,
Thank you for your reply, I will follow you advice, it saves me a lot of time.
 
Consider Paul's rocket mass heater.
 
subject: NX: width proportion in DefaultTableModel
 
Similar Threads
DefaultTableModel and DefaultComboBoxModel
JTable problem
JTable delete row problem
set rows color in JTable
Suppress the Cell color change on Focus