I have a main frame which displays results from my database, however when I delete, edit or add an entry from another frame I am looking to update my main frames results.
I originally had a method in the main frame which re-validated whenever the button to add, delete or update was pressed. However, this just created a new main frame on top of the old frame.
So my question would be, how would I re-validate the original frame, without creating new frames, from a different class?
EDIT: Sorry, I probably wasn't very clear on what was happening, let me clarify.
So on my MainFrame I have a JLabel which displays upcoming appointments retrieved from my database.
If an appointment is added, deleted or updated I want this JLabel to be re-validated. Currently I have this method in the MainFrame class
public void refreshFrame(){
revalidate();
}
Which is called whenever an appointment is modified
delete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Database db = new Database();
db.deleteAppointmentDB(appointmentIDField.getText());
JOptionPane.showMessageDialog(null, "Appointment has been deleted.");
MainFrame mf = new MainFrame();
mf.refreshFrame();
dispose();
However, this seems to just create a new MainFrame, rather than updating the original frame.