You need an architecture.
You application does not need to have a visible JFrame - therefor your application can also have multiple JFrames.
Your Main-class - starting point for the application - needs to trigger a basic application
without GUI.
That basic application defines the lifecycle. When it is closed down the application is finished.
The basic application has one major task: it's holding the data, so that different JFrames can access it:
public class Main {
private static Facade oFacade = new Facade();
public static void main(String[] args) {
startFacade();
startGUI();
}
private static void startGUI() {
new GUI(oFacade);
}
private static void startFacade() {
oFacade.init();
}
}
The concept of a facade is a common pattern in Java development (
Wikipedia on facade pattern[
^]
public class Facade {
public void init() {
}
}
public class GUI{
public GUI(Facade oFacade) {
}
}
That is basically also what an application framework does for you - much richer, much more complex.