I want to set width of each column...
Means I want to change width of each column..
In this given code width of each column is same...
But I want each column of different width...
as Like 1st column is of width 50,2ed is of 100,3rd is of 120....
Please make change in this given code ...
haw can i change width of each column
Your program is good that has no problem. But you can use TableColumn and DefaultTableColumnModel instead of directly add column to table. It has more methods to change column's model, width, fontcolor etc.,
Here is Sample Program...
TableColumn and DefaultTableColumnModel both are present in
1. One usage tablecolumn model directly as mentioned in earlier comment.
2. You can set the column size explicitly by setWidth method
here is the sample:
Dimension dim = table.getPreferredSize();
int width = dim.width / 4;
table.getColumnModel().getColumn(1).setPreferredWidth(width * 15);
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad: