Click to See Complete Forum and Search --> : Can I set width of each column in JTable ?


kee149
May 9th, 2004, 12:40 AM
Can I set width of each column in JTable ? Is it possible?

Thanks
Kee

dlorde
May 9th, 2004, 02:17 PM
Yes, see the setPreferredWidth() (http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/table/TableColumn.html#setPreferredWidth(int)) method in the TableColumn (http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/table/TableColumn.html) class and TableColumnModel (http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/table/TableColumn.html) (also DefaultTableColumnModel (http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/table/DefaultTableColumnModel.html) which is provided by default).

One can think effectively only when one is willing to endure suspense and to undergo the trouble of searching...
J. Dewey