Re: moving (JTable) columns



On Sun, 27 Nov 2005 07:46:46 -0500, ":-o" <fcrutch@xxxxxxxxxxxx>
wrote, quoted or indirectly quoted someone who said :

>I think I know whats happening. I have a constants file with final public
>static definitions and within this
>file, I have an final public static array which controls the columns that the
>s/w is locked into, which I'll need to redesign.
>
>final public static String[] columns {"SSN", "LastName", "FirstName", etc......}
>
>such that when I do a findColumn (after column movement), this is where it
>hiccups.

1. JTable has a get TableColumnModel() method.

2. You can then use getTableColumn( i ) to get the TableColumn object
for the ith column.

3. your TableColumn object has a method getModelIndex() that tells
where the data for that column comes from in the model.

When any column moves, the mapping for step (2) changes, and listeners
can get a columnMoved event.

I don't think you should be doing any findColumn.

For an experment set up a TableColumnModelListener that fires a
fireTableDataChanged.

That is not the proper solution, but if that solution fails, you know
the problem is not in failing to refresh.

Are you caching any of the TableColumns? you have to refresh that
after a colmunMoved.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
.