Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

HowTo exit from an application

Thread view: 
Flex - 05 May 2006 17:27 GMT
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
Oliver Wong - 05 May 2006 17:33 GMT
>I have an application that use awt and Swing, with this code :
>
[quoted text clipped - 8 lines]
> 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
Flex - 05 May 2006 21:16 GMT
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
Oliver Wong - 05 May 2006 23:11 GMT
> Il Fri, 05 May 2006 16:33:52 +0000, Oliver Wong ha scritto:
>
[quoted text clipped - 3 lines]
>
> 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
Flex - 06 May 2006 17:49 GMT
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
Oliver Wong - 08 May 2006 15:00 GMT
> 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
Flex - 08 May 2006 16:57 GMT
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
Oliver Wong - 08 May 2006 17:29 GMT
> Il Mon, 08 May 2006 14:00:57 +0000, Oliver Wong ha scritto:
>
[quoted text clipped - 9 lines]
> 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
Kova - 06 May 2006 19:37 GMT
> 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
Flex - 08 May 2006 16:53 GMT
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
Sigmund Hansen - 08 May 2006 19:31 GMT
> Il Sat, 06 May 2006 20:37:42 +0200, Kova ha scritto:
>
[quoted text clipped - 9 lines]
> _____
> FleX

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.