469,292 Members | 1,306 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,292 developers. It's quick & easy.

HowTo exit from an application

I have an application that use awt and Swing, with this code :

public void windowClosing(WindowEvent e) {
Window window = e.getWindow();
if (window.equals(this)) {
setVisible(false);
dispose();
}
}

But when I close it some resources remain occuped and I can have prompt
until I press CTRL C. Why ?

_____
Flex
May 5 '06 #1
10 11770
"Flex" <fl******@ammsreprogrammareweb.com> wrote in message
news:pa****************************@ammsreprogramm areweb.com...
I have an application that use awt and Swing, with this code :

public void windowClosing(WindowEvent e) {
Window window = e.getWindow();
if (window.equals(this)) {
setVisible(false);
dispose();
}
}

But when I close it some resources remain occuped and I can have prompt
until I press CTRL C. Why ?


The easiest way to get your program to quit when you close the window is to
use the setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

- Oliver

May 5 '06 #2
Il Fri, 05 May 2006 16:33:52 +0000, Oliver Wong ha scritto:
The easiest way to get your program to quit when you close the window is to
use the setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


It's the same, I don't understand why, but something remains open..

____
FleX

May 5 '06 #3

"Flex" <fl******@ammsreprogrammareweb.com> wrote in message
news:pa****************************@ammsreprogramm areweb.com...
Il Fri, 05 May 2006 16:33:52 +0000, Oliver Wong ha scritto:
The easiest way to get your program to quit when you close the window is
to
use the setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


It's the same, I don't understand why, but something remains open..


Can you post an SSCCE demonstrating the problem?
http://mindprod.com/jgloss/sscce.html

- Oliver

May 5 '06 #4
Il Fri, 05 May 2006 22:11:11 +0000, Oliver Wong ha scritto:
Can you post an SSCCE demonstrating the problem?
http://mindprod.com/jgloss/sscce.html


it'is not simple, because this is a big application, with some class, I
need a method to understand what remains open after exit.

___
FleX

May 6 '06 #5
Flex wrote:
But when I close it some resources remain occuped and I can have prompt
until I press CTRL C. Why ?


Like, command prompt? Well if run your program from command prompt (like
"java MyClass") of course then it will return to wherever it started
from... and that's command prompt.
If not, you didn't close the "main" thread (like JFrame thing Oliver
suggested) or have some other thread running.

--
Kova
May 6 '06 #6
"Flex" <fl******@ammsreprogrammareweb.com> wrote in message
news:pa****************************@ammsreprogramm areweb.com...
Il Fri, 05 May 2006 22:11:11 +0000, Oliver Wong ha scritto:

it'is not simple, because this is a big application, with some class, I
need a method to understand what remains open after exit.


What about having an observer that all the windows notify when they open
or close, and so the observer always has an accurate list of the open
windows, and can exit as appropriate?

- Oliver

May 8 '06 #7
Il Sat, 06 May 2006 20:37:42 +0200, Kova ha scritto:
Like, command prompt? Well if run your program from command prompt (like
"java MyClass") of course then it will return to wherever it started
from... and that's command prompt.
If not, you didn't close the "main" thread (like JFrame thing Oliver
suggested) or have some other thread running.


I run the GUI program from a x-terminal and when I close it, javaVM
remain in memory, but I cannot understand why..

_____
FleX
May 8 '06 #8
Il Mon, 08 May 2006 14:00:57 +0000, Oliver Wong ha scritto:

What about having an observer that all the windows notify when they open
or close, and so the observer always has an accurate list of the open
windows, and can exit as appropriate?


it's strange, when I try to run the application in debug mode (with
Netbeans) i receive this error :
Listening on 55850
User program running
Breakpoint hit at line 497 in class java.lang.Integer by thread main.
Thread main stopped at Integer.java:497.

and the application doesn't run.

____
FleX

May 8 '06 #9

"Flex" <fl******@ammsreprogrammareweb.com> wrote in message
news:pa****************************@ammsreprogramm areweb.com...
Il Mon, 08 May 2006 14:00:57 +0000, Oliver Wong ha scritto:

What about having an observer that all the windows notify when they
open
or close, and so the observer always has an accurate list of the open
windows, and can exit as appropriate?


it's strange, when I try to run the application in debug mode (with
Netbeans) i receive this error :
Listening on 55850
User program running
Breakpoint hit at line 497 in class java.lang.Integer by thread main.
Thread main stopped at Integer.java:497.


Remove the breakpoint, or press continue on the debugger.

- Oliver

May 8 '06 #10
Flex wrote:
Il Sat, 06 May 2006 20:37:42 +0200, Kova ha scritto:
Like, command prompt? Well if run your program from command prompt (like
"java MyClass") of course then it will return to wherever it started
from... and that's command prompt.
If not, you didn't close the "main" thread (like JFrame thing Oliver
suggested) or have some other thread running.


I run the GUI program from a x-terminal and when I close it, javaVM
remain in memory, but I cannot understand why..

_____
FleX


Have you tried adding System.exit(0); ???
It's a classic when it comes to closing an app...
May 8 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Rene Crespo | last post: by
4 posts views Thread by Chuck | last post: by
3 posts views Thread by Zack Whittaker \(R2 Mentor\) | last post: by
1 post views Thread by kong | last post: by
3 posts views Thread by Simon | last post: by
1 post views Thread by Daniel | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.