Image

Imageerikwilson wrote in Imagejava_dev

Listens: 3 - Mozart - Sonata for Violin and Piano, in B flat Major, K.378 (317d) - Rondeau (Allegro) (M O S T L Y - C L A S S I C A L - Relax... it's good for you! (powered by Digitally Imported))

Here's a qustion.

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.