| 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: 10816
|
|
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: 18670
|
|
|
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.
|
 |
 |
|
|
subject: NX: width proportion in DefaultTableModel
|
|
|