|
Here's what I'm trying to do....Maybe someone will have some ideas.
Right now I want to associate an ActionListener with a JMenuItem that will close the currently open window but not shut down my program. I have one window open that will launch another window (JFrame). I want to have a JMenuItem(File->Exit) that will close the newly opened window, while leaving the parent window functioning.
In other words, I don't want to call System.exit(0) to close my new window and kill my program.
Here is what I have now.
ActionListener exitListener = new ActionListener() { public void actionPerformed(ActionEvent e) { ((Window) e.getSource()).dispose(); } };
exitMenuItem.addActionListener(exitListener);
I know this isn't working right because e is an ActionEvent and not a WindowEvent but I'm running out of ideas to try to get this to work and I'm thinking this is kinda in the right direciton.
Any input would be appreciated.
|