I made an application that gives the user the opportunity to fully open a new caviar of the application. When the user does this and closes the application, the entire application terminates; not just a window.
How should I look for the application spawning recursively, and then when the user exits the JFrame calf; killing only JFrame and not the whole instance?
Here is the relevant code:
[...]
JMenuItem newMenuItem = new JMenuItem ("New");
newMenuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
new MainWindow();
}
});
fileMenu.add(newMenuItem);
[....]
JMenuItem exit = new JMenuItem("Exit");
exit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
});
fileMenu.add(exit);
[...]
anon235370
source
share