JTable with AUTO_RESIZE_OFF not resizing at all!
I tried to find solution in other posts, but no success.
I created a JTable with
table.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
That磗 fine, but now I can磘 resize it at all while interacting with it.
That磗 the main code of the table.
I磀 appreciate any any help.
Thanks in advice.
int preferredWidth = 0;
int preferredSizeSum = 0;
//Rebuild TableColumnModel with correct number of columns
((AbstractTableModel)getTable().getModel()).fireTableStructureChanged();
//Set the columns widths based on the field data
TableColumnModel columnModel = getTable().getColumnModel();
for (int i = 0; i <= multiProperties.size(); i++){
TableColumn column = columnModel.getColumn(i);
//Start with the reported column width
preferredWidth = column.getWidth();
//Enforce minimum width needed to display column header text
preferredWidth = Math.max(preferredWidth, ((AbstractTableModel)getTable().getModel()).getColumnName(i).length() * 10);
//Enforce maximum width so long fields get truncated
preferredWidth = Math.min(preferredWidth, 200);
//Set the column width
column.setPreferredWidth( preferredWidth );
column.setMinWidth( 5 );
column.setMaxWidth( 500 );
preferredSizeSum += preferredWidth;
}
getTable().setMaximumSize(new Dimension( 500*multiProperties.size(), tableHeight ) );
getTable().setMinimumSize(new Dimension( 5*multiProperties.size(), tableHeight ) );
getTable().setPreferredSize(new Dimension( preferredSizeSum, tableHeight ) );
getTable().setSize(new Dimension( preferredSizeSum, tableHeight ) );

