Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #436
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!transit4.readnews.com!textspool2.readnews.com!news-out.readnews.com!transit3.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail |
|---|---|
| From | "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> |
| Subject | Re: closing a specific JF |
| Message-ID | <1166483007.396950.128280@l12g2000cwl.googlegroups.com> (permalink) |
| X-Comment-To | comp.lang.java.gui |
| Newsgroups | comp.lang.java.gui |
| In-Reply-To | <1166480819.702914.157250@n67g2000cwd.googlegroups.com> |
| References | <1166480819.702914.157250@n67g2000cwd.googlegroups.com> |
| Content-Type | text/plain; charset=IBM437 |
| Content-Transfer-Encoding | 8bit |
| X-Gateway | time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] |
| Lines | 46 |
| Date | Wed, 27 Apr 2011 15:27:31 GMT |
| NNTP-Posting-Host | 96.60.20.240 |
| X-Complaints-To | news@tds.net |
| X-Trace | newsreading01.news.tds.net 1303918051 96.60.20.240 (Wed, 27 Apr 2011 10:27:31 CDT) |
| NNTP-Posting-Date | Wed, 27 Apr 2011 10:27:31 CDT |
| Organization | TDS.net |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.gui:436 |
Show key headers only | View raw
To: comp.lang.java.gui
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.
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar
closing a specific JFrame "William Z." <william.z.@THRWHITE.remove-dii-this> - 2011-04-27 15:27 +0000
Re: closing a specific JF "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> - 2011-04-27 15:27 +0000
Re: closing a specific JF "William Z." <william.z.@THRWHITE.remove-dii-this> - 2011-04-27 15:27 +0000
Re: closing a specific JF "Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this> - 2011-04-27 15:27 +0000
csiph-web