I have a Java app that displays a list from a database. Inside the class is the following code to open a new dialog for data entry:
@Action
public void addNewEntry() {
JFrame mainFrame = ADLog2App.getApplication().getMainFrame();
addNewDialog = new AddNewView(mainFrame, true);
addNewDialog.setLocationRelativeTo(mainFrame);
addNewDialog.addContainerListener(null);
ADLog2App.getApplication().show(addNewDialog);
}
How do you add a listener to the main class to detect when the addNewDialog window is closed, so that I can call a refresh method and refresh the list from the database.
If
AddNewViewis aWindowsuch as aDialogorJDialog, you could use the Window.addWindowListener(…). That is, in your main class, you dowhere
someWindowListeneris someWindowListener(for instance aWindowAdapter) which overrides / implemetnnswindowClosed.A more complete example, using an anonymous class, could look like
Relevant links: