Copy row from one table to another

Hi,

I've made a component which allows you to copy rows from one JTable to another. I have one small problem though .. you can switch the columns in different order by dragging the header. Since I'm copying one column at the time (col1, col2, col3 to col1, col2, col3) a problem exists when you switch the column position (col1, col3, col2 to col1, col2, col3) . Is there any way to copy one entire row (in the correct position) from one JTable to the other ?

[474 byte] By [ReggieBEa] at [2007-11-27 5:15:16]
# 1

I'm guessing that you are using:

table.getValueAt(....)

to get all the values as you copy from one table to another. As you have noticed this gets the data based on the view of the data in the table and the view can change.

So you should be using:

table.getModel().getValueAt(...)

This will get the data directly from the TableModel in the order in which the columns where added to the TableModel. The column order does not change.

camickra at 2007-7-12 10:37:26 > top of Java-index,Desktop,Core GUI APIs...