Hi,
I hava a table in a scrollPane
. There are 6 columns in my table. I want the last 2 columns to be wider than other columns. But after I set the size of the columns, the vertical scroll bar disappeared. If I comment out the code for resetting the columns width, everything goes back to normal. Could anyone tell me what's the problem of this? Thanks a lot!!
I copied several related dimentions blow:
table.setPreferredScrollableViewportSize(new Dimension(900, 500));
feedback = new JScrollPane(table);
feedback.setMinimumSize(new Dimension(900, 400));
the code to resize the columns:
TableColumn column = null;
for (int i = 0; i < 6; i++) {
column = table.getColumnModel().getColumn(i);
if (i == 4) {
column.setPreferredWidth(250); //third column is bigger
} else {
if (i==5) {
column.setPreferredWidth(250);
}
else {
column.setPreferredWidth(100);
}
}
}