Refresh table in parent frame when child closes
I'm trying to refresh a table in a parent frame when the child frame is closed, by clicking the save button.
Code to setup parent frame table:
sorter =new TableSorter(new MyTableModel());
tbl_Applicators.getTableHeader().setReorderingAllowed(false);
tbl_Applicators.setModel(sorter);
class MyTableModelextends AbstractTableModel{
public MyTableModel()throws Exception{
columnNames = dataHandler.getApplicatorColumns();
data = dataHandler.getApplicatorTable();
}
publicint getColumnCount(){
return columnNames.length;
}
publicint getRowCount(){
return data.length;
}
public String getColumnName(int col){
return columnNames[col];
}
public Object getValueAt(int row,int col){
return data[row][col];
}
publicboolean isCellEditable(int row,int col){
returnfalse;
}
}
Code in parent frame to create child frame:
publicvoid but_Add_actionPerformed(ActionEvent e){
JFrame add;
if ( ok to make frame ){
add =new Edit_Applicator("Add Applicator", 370, 500, dataHandler, true, sorter);
add.addWindowListener(new java.awt.event.WindowAdapter(){
publicvoid windowClosing(WindowEvent winEvt){
do things
}
publicvoid windowClosed(WindowEvent winEvt){
do things
}
});
}
}
Code in child to close window:
publicvoid but_Save_actionPerformed(ActionEvent e){
writenew data to database
this.dispose();
}
the data in the table is stored in a database, and i need to refresh the table when the data is saved from the child frame

