tags:

views:

182

answers:

2
+1  A: 
fixedTable.setColumnModel(table.getColumnModel());

The problem lies in that line. If you comment it out the Table behaves normally. If that breaks your code (As I don't know what you want to do exactly) just comment.

But as you added in your comment, you want to sync the two tables. I found a forum thread that covers exactly that problem:

http://forums.sun.com/thread.jspa?threadID=713021

Have fun!

P.S.: Just in case the forum thread vanishes (Just copied the text):

First hook up the tables. Had to share the ColumnModel otherwise it did not work. The panels both have a JTable field and the set and get ColumnModel methods delegate to the

JTable.
infoPanel.setColumnModel(overviewPanel.getColumnModel());
overviewPanel.getColumnModel().addColumnModelListener(infoPanel);    
infoPanel.getColumnModel().addColumnModelListener(overviewPanel);

Then handle the ChangeEvent:

public void columnMarginChanged(ChangeEvent event) {
final TableColumnModel eventModel = (DefaultTableColumnModel)event.getSource();
final TableColumnModel thisModel = getTable().getColumnModel();
final int columnCount = eventModel.getColumnCount();


for (int i = 0; i < columnCount; i++) {
  thisModel.getColumn(i).setWidth(eventModel.getColumn(i).getWidth());
}
repaint();
}
das_weezul
Yes, but this is the key line of this component, both tables have to share the same column model so that if enyone moves or resizes a column in the upper table it will automatically reflect those changes in the bottom table.
Adalbert25
OK that should do the trick! You should have mentioned the syncing of the column widths before, as it seems to be the main problem here. Good Luck!
das_weezul
A: 

I have ran into this post during my research in this matter and it have proven to be quite helpful together with some other bits of code and by putting it all together I have managed to come up with a working solution of always visible summary row supporting sorting column resize and moving. Quite neat I have to say. I'll try to post a sample code. Thanks for your help!

Adalbert25