I have a Java application that is used to run the Swing user interface. An interface is a class with an encapsulated JFrame instance. The problem is that the application allocates some resources, and the Swing interface uses these resources, but the application closes the resource, not the user interface.
How can I achieve either the main application receives a notification when the full Swing interface is closed, or that the beginning of the Swing interface is blocked until it is closed. Closed means that the WindowAdapter.windowClosed(WindowEvent) method for the JFrame WindowListener has already been called.
The solution to this topic ( link ) seems to be back when the JFrame is invisible, does this include WINDOW_CLOSED event WINDOW_CLOSED ?
Edit: Perhaps this will be the solution to implement this lifecycle interface:
public interface Lifecycle { public void startup(); public void shutdown(); }
Now the Swing interface class should call the shutdown() method of the main application in the WindowEvent.WINDOW_CLOSED event handler .
Is this a good mark possible?
source share