I try to pass a JTable1 to JTable2, however I do not want the last 2 columns of the JTable1 to be passed. Thank you in advance !!!
I try to pass a JTable1 to JTable2, however I do not want the last 2 columns of the JTable1 to be passed. Thank you in advance !!!
You could copy the values cell by cell, only from the columns that interest you. Ex: JTable1
|col1 |col2 |col3 |col4|
|1 |2 |3 |4 |
|5 |6 |7 |8 |
JTable 2 would be:
|col1 |col2 |
|1 |2 |
|5 |6 |
And the code would be:
for(int i=0; i<jTable1.getRowCount(); i++){
Object fila[] = new Object[2];
DefaultTableModel modelo = (DefaultTableModel) jTable2.getModel();
fila[0] = String.valueOf(jTable1.getValueAt(i, 0);
fila[1] = String.valueOf(jTable1.getValueAt(i, 1);
modelo.addRow(fila);
}
I do not know if that helps you to copy them, if I did not understand well I wait for your answer to try to help you! Greetings!