Vanavah Edwards
asked on
How do I set the column width for selected columns in a JTable
For this line ---> table.getColumn(2).setPref erredWidth (10);
i am getting this ERROR --->>
Exception in thread "main" java.lang.IllegalArgumentE xception: Identifier not found
at javax.swing.table.DefaultT ableColumn Model.getC olumnIndex (Unknown Source)
at javax.swing.JTable.getColu mn(Unknown Source)
at browseSelect.main(browseSe lect.java: 113)
i am getting this ERROR --->>
Exception in thread "main" java.lang.IllegalArgumentE
at javax.swing.table.DefaultT
at javax.swing.JTable.getColu
at browseSelect.main(browseSe
JTable table = new JTable(browseList, headersV);
JScrollPane scrolls = new JScrollPane(table,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
table.getColumn(2).setPreferredWidth(10);
But befire you do anything - popuate your table and look at it.
Why do you want to chaneg column size?
In majority of tables you dont need to do it
Why do you want to chaneg column size?
In majority of tables you dont need to do it
As you see to do it - you need to disable autoaddjustment - so you'll take a lot of unneccassry responsibilities upon yourself - let
swing do its job - it ill in most case do a better job
swing do its job - it ill in most case do a better job
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
look here:
http://www.exampledepot.com/egs/javax.swing.table/ColSize.html
Open in new window