Hello,
I've got a problem with putting data into a JTable with a defaultTableModel from another class.
Here is some example code
i've got a actionPerformed in class A
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==ok)
{
getDate();
verlofTabel test = new verlofTabel();
Object[] tempRow = new Object[]{"test1", "test2", "test 3", "test 4", "test5"};
test.addRow(tempRow);
this.setVisible(false);
}
}
The Object[] tempRow has to update my DefaultTableModel in class B
public class verlofTabel extends JPanel {
private Object[][] databaseInfo;
private JScrollPane pane;
public Object[][] getDatabaseInfo() {
return databaseInfo;
}
public void setDatabaseInfo(Object[][] databaseInfo) {
this.databaseInfo = databaseInfo;
}
private String[] columns = {"Begin datum", "Eind datum", "Uren berekend", "Werkelijke uren", "Opmerkingen"};
private MyTableModel dTable = new MyTableModel(databaseInfo, columns);
public verlofTabel()
{
JTable tabelVerlof = new JTable(dTable);
this.add(new JScrollPane(tabelVerlof));
}
public void addRow(Object[] row)
{
dTable.addRow(row);
System.out.println("row added");
}
}