Re: closing a specific JFrame of several
- From: "Daniel Pitts" <googlegroupie@xxxxxxxxxxxxx>
- Date: 18 Dec 2006 15:03:27 -0800
William Z. wrote:
I have a JFrame that, when I click "new" in the menu bar, creates
another JFrame like that of the first. It just runs the following code
...
EventQueue.invokeLater(new Runnable() {
public void run() {
MyApp app = new MyApp();
app.createGUI();
}
});
And inside the createGUI() method is this ...
addWindowListener(new WindowListener() {
public void windowOpened(WindowEvent arg0) {}
public void windowClosed(WindowEvent arg0) {}
public void windowIconified(WindowEvent arg0) {}
public void windowDeiconified(WindowEvent arg0) {}
public void windowActivated(WindowEvent arg0) {}
public void windowDeactivated(WindowEvent arg0) {}
public void windowClosing(WindowEvent arg0) {
System.exit(0);
}
});
As it works right now, when I close a window, all the windows close and
I'd just like to close only that specific window in which the user
clicked the close button.
Any help much appreciated.
The System.exit(0); call tells the JVM to terminate the program....
Don't use the addWindowListener at all, instead what you really want is
to call
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
Hope this helps,
Daniel.
.
- Follow-Ups:
- Re: closing a specific JFrame of several
- From: William Z.
- Re: closing a specific JFrame of several
- References:
- closing a specific JFrame of several
- From: William Z.
- closing a specific JFrame of several
- Prev by Date: Re: Windows Decoration Listeners? - Problem Solved
- Next by Date: Re: closing a specific JFrame of several
- Previous by thread: closing a specific JFrame of several
- Next by thread: Re: closing a specific JFrame of several
- Index(es):