0

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.

Buupu
  • 67
  • 1
  • 8
  • 1
    Please show the code, it would help the people answering your question. – pinkpanther May 29 '16 at 22:35
  • *"how would I re-validate the original frame, without creating new frames, from a different class?"* If a dialog adds a new item to a list model that is displayed in the frame, the list in the frame will automatically update. Which then raises the question of 'what the heck is your code doing and how?'. Post a [mcve]. – Andrew Thompson May 29 '16 at 22:41
  • *"from another frame"* Those 'frames' should be dialogs (`JDialog`) and possibly modal dialogs (that block code after the `modalDialog.setVisible(true)` statement is called, until it is closed). See also [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) – Andrew Thompson May 29 '16 at 22:43

0 Answers0