| Author |
JTable column width
|
Alex Gregory
Ranch Hand
Joined: Jun 15, 2002
Posts: 46
|
|
|
Hi, some of my columns are more wide than need to be and some are so narrow that the column header name is shortened and followed by dots. How can I make the JTable draw such that every column fits and no column header name is abridged and followed by dots?
|
 |
Rishi Yagnik
Ranch Hand
Joined: Jan 04, 2001
Posts: 84
|
|
Hi I think use JTable.setPreferredWidth() for columns will definately help u ..... I have done with the help of that...... pls do tell me if i am missing something Rishi
|
 |
Eduard Jodas
Ranch Hand
Joined: May 14, 2002
Posts: 80
|
|
|
You should access the TableColumnModel of the JTable. Then access each individual column and set its width. But first of all you should turn off the auto-resize columns capability of the Table.
|
 |
Alex Gregory
Ranch Hand
Joined: Jun 15, 2002
Posts: 46
|
|
|
Thanks, but should I hard code the widths or should I set the width of each column based on the width of its header name?
|
 |
Eduard Jodas
Ranch Hand
Joined: May 14, 2002
Posts: 80
|
|
That's up to you. Personally, I have hardcoded the widths because some columns are wider than their header name.
|
 |
Alex Gregory
Ranch Hand
Joined: Jun 15, 2002
Posts: 46
|
|
|
Thanks everyone, I figured out how to set the widths of the columns.
|
 |
 |
|
|
subject: JTable column width
|
|
|