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 ) );

[2207 byte] By [Willena] at [2007-10-3 9:49:39]
# 1

Works fine for me:

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=623692

If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the code retains its original formatting.

camickra at 2007-7-15 5:06:44 > top of Java-index,Desktop,Core GUI APIs...