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.
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
Joined: Jul 28, 2003
Hi, Andrew and Jim, Thank you for your reply, I will follow you advice, it saves me a lot of time.