Is there a way to copy selected columns from a single table and add it to another Jtable? The way I'm trying to do this is to have the add and remove buttons left of the second table to add the selected columns from the above table and remove button to remove those columns I initially added. I'm new and currently learning how to use JavaSwing, but I'm unsure how I would implement this.
private void RemoveColBActionPerformed(java.awt.event.ActionEvent evt) {
// Removes the column copied :
DefaultTableModel model2 =(DefaultTableModel) CopiedTables.getModel(); // New Table
}
private void AddBActionPerformed(java.awt.event.ActionEvent evt) {
//Add Data
lMessage.setText("");
DefaultTableModel model =(DefaultTableModel) JtableData.getModel();
if(!ProdNameTF.getText().trim().equals("")) {
model.addRow(new Object []{ProdNameTF.getText(), CategoryCB.getSelectedItem().toString(), PriceTF.getText()});
} else {
lMessage.setText("Message Left Blank");
}
}
private void AddColBActionPerformed(java.awt.event.ActionEvent evt) {
// Adds the column copied
DefaultTableModel model =(DefaultTableModel) JtableData.getModel(); //Old Table
DefaultTableModel model2 =(DefaultTableModel) CopiedTables.getModel(); // New Table
}