Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ApplicationListeners & shutting down in Java 1.4



Are either of you guys making direct or indirect calls to System.exit() or Runtime.halt()? If you remember the "old" way to exit a GUI was to put one of these (almost always System.exit()) in a callback. Believe it or not, this was actually a bug. On Java version (I think 1.4.1 and greater) such programs can be terminated without doing this. Terminating a program via System.exit() is kind of like stopping a car by setting off a stick of dynamite in that it takes everything down along with it. IF, and it's a big IF I recall correctly, you can dispose of the GUI elements using dispose() on the parent object and the other threads will continue running until they're done, and then the program will exit (assuming it's supposed to).

The following code snippet shows a modified program that gets rid of the call to exit (System.exit(0); is commented out below)

class NotHelloWorldFrame extends JFrame
{  public NotHelloWorldFrame()
   {  setTitle("NotHelloWorld");
      setSize(300, 200);
      addWindowListener(new WindowAdapter()
         {  public void windowClosing(WindowEvent e)
            {//  System.exit(0);
            dispose();
            }
         } );

I don't know if this addresses your problem or not.

In any case, good luck,

Bill Wagner



Morgan Schweers wrote:
Greetings,
On 10/12/05, Jeremy Wood <email@hidden> wrote:

In all our Java 1.4 apps on Mac, we have a minor bug when it comes to
shutting down.


[...deletia...basically either lose changes, or 'cancel' shutdowns...]


The bug is this: in our current implementation, we correctly close the
application when requested, but if the quit is a result of the user's
attempt to log off/shutdown/restart, then we're always told "The
application X has cancelled shutdown/restart/etc."


I have the exact same problem, and I resolve it by apologizing to the
users who report it, and explaining that as far as I know, there's no
real choice in Java on the platform.  :(

Yes, it peeves me (and my users), but I've found no workarounds in a
good bit of searching.  My best approach is to provide a 'Don't show
me this anymore' checkbox, and if the user has selected it (i.e. has
theoretically made a knowledgable choice), always save-and-close,
which can be done w/o queuing a QUIT message to the UI thread.

Anyone else who has a workaround, it'd be great to hear...

--  Morgan Schweers, CyberFOX!
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >ApplicationListeners & shutting down in Java 1.4 (From: Jeremy Wood <email@hidden>)
 >Re: ApplicationListeners & shutting down in Java 1.4 (From: Morgan Schweers <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.