« Looking for a Job | Main | Digital Copyright paper »

Java rant: TableColumnModel.moveColumn()

I'm trying to save and restore the order/size of columns in a JTable. So, I've saved the order of the columns, and now I want to restore it. I know that all the columns are there. So I need to shuffle them around. What's the way to do it? TableColumnModel.moveColumn():

Moves the column and its header at columnIndex to newIndex. The old column at columnIndex will now be found at newIndex. The column that used to be at newIndex is shifted left or right to make room.

Wait. Does it shift the old column left, or does it shift it right? It's rather important that I know, or else I can't get my algorithm correct.

Comments

Writing some simple tests will let you determine how the columns shift in various scenarios.

Yeah, and I can go and look at the source for DefaultTableColumnModel. I'm just cranky that I _have_ to. The spec should either clearly say what the function does, or clearly say that you can't depend on its operation.

Post a comment