Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (534)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Mac's Command-Q effect on Java?  (Read 3109 times)
0 Members and 1 Guest are viewing this topic.
Offline Evanstaul

Senior Newbie





« Posted 2006-07-21 07:38:55 »

I've already had a user complaint on this.  On Windows Alt+F4 seems like a good window close event, while on Mac, Command-Q seems like it's a direct end-program with no time to cleanup.  Does anyone have experience with this?

Thanks!
Offline Coinerson

Junior Member




Introducing the world's cutest zombie, Timmy


« Reply #1 - Posted 2006-07-23 06:03:26 »

Cmd-Q cleans up....
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #2 - Posted 2006-07-26 20:35:34 »

On Mac you should be using Apple's classes to hook into the Command-Q event.  Apple supplies stubs so you can compile on any platform, you just check at runtime if you are on a Mac and activate the hooks.   Check the java.net tutorial for bringing your apps to the Mac.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Kova

Senior Member





« Reply #3 - Posted 2006-07-27 12:38:05 »

??
Isn't Java supposed to be cross platform  Embarrassed
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #4 - Posted 2006-07-27 22:44:35 »

It is.

What has that got to do with platform specific features like Command-Q ?

If you want to support platform specific things, you need to code for them.

It's not hard.

Offline Kova

Senior Member





« Reply #5 - Posted 2006-07-27 23:19:01 »

Ah.. don't know about command-q, thought it was like alt-f4 in windows, a close application call.
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #6 - Posted 2006-07-27 23:50:11 »

Alt-F4 is a Close Window call, isn't it?

Command-Q is a quit application call on Mac.  It does not have anything to do with closing a window in any direct sense.

Offline Kova

Senior Member





« Reply #7 - Posted 2006-07-28 00:09:23 »

in windows, window = application Sad
 ... so far I didn't stumbled on application that dosen't completely close after alt-f4 (if not ignored of course).
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #8 - Posted 2006-07-28 04:49:13 »

in windows, window = application Sad
 ... so far I didn't stumbled on application that dosen't completely close after alt-f4 (if not ignored of course).

Windows has multi-window applications too..  For example: explorer.exe can be configured to run all windows froma single process.  GIMP for windows uses multiple windows.

Offline Anon666

Junior Member




aka Abuse/AbU5e/TehJumpingJawa


« Reply #9 - Posted 2006-07-31 14:25:49 »

By the sound of it, Command+Q is equivalent to clicking "End Task" in task manager?

If that is the case, unless you specifically want to remap or disable the functionality of Command+Q, should the shutdown code not be performed using the platform independant mechanism exposed through shutdown hooks?
e.g.
java.lang.Runtime.getRuntime().addShutdownHook(new Thread(new CustomCleanerupper()));
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #10 - Posted 2006-07-31 15:55:14 »

No, not at all.

End Task in task manager forcibly shuts down the process on Windows.  Your application doesn't get a chance to do anything, as far as I know.

Command-Q is not a "forced quit", it's a "quit request" distinct from a "close window" request.  Both Windows apps and Mac apps can run without a window open, though it is more common on a Mac, since it has a screen-level menu bar so you can still interact with the application.

Shutdown hooks are good for clean up, but you can't stop the shutdown.  Mac also has "Forced Quit" which you can get to in a couple ways... one is if the main GUI thread is stuck for too long the doc icon for the app will have "Force Quit" instead of "Quit" in the context menu.

When someone hits Command-Q with an unsaved document, you might pop up a dialog asking "Save your work?", "Don't Save", "Cancel" ... so you can cancel the shutdown.

On Mac you want to hook into some standard menus in a Mac-friendly way.  On Mac all applications have a "Application" menu that has the name of the app and is the first menu on the menu bar, before the typical File menu.   The Quit item always goes in that Menu, the Preferences menu item should always go in that menu, the About item always goes in that menu.  It isn't hard to use the Apple-supplied stub classes to compile something on Windows that would use these items on Mac.  It is good practice to detect that you are on a Mac and remove "Exit" from your "File" menu and instead hook the same code up to the Application menu's "Quit" which is the same thing that happens when you press Command-Q.  The same thing should happen with your About item, that would typically be in the Help menu on Windows, but should only be in the Application menu on Mac.  Java/Swing doesn't provide any suitable framework for encapsulating these concepts in a cross-platform way... though I think there is a Swing-related JSR for an Application Framework to address this.

Offline Anon666

Junior Member




aka Abuse/AbU5e/TehJumpingJawa


« Reply #11 - Posted 2006-08-01 10:40:05 »

No, not at all.

End Task in task manager forcibly shuts down the process on Windows.  Your application doesn't get a chance to do anything, as far as I know.


'End Process' has the behaviour you describe there.

'End Task' appears to behaviour in a near identical fashion to Command+Q.
I assume it sends a message with the meaning of "please terminate the application soon", because if the application is still active in 5 seconds time the OS assumes it has stopped responding and pops up its own dialog querying whether you wish to forceably terminate the application.

I was completely unaware of the Mac's standardized mechanism for displaying certain menu items; it is interesting that Swing hasn't yet addressed this limitation.
A great reason to design applications so they are sufficiently intuitive to not require menu bars! =)
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (35 views)
2014-07-24 01:59:36

Riven (33 views)
2014-07-23 21:16:32

Riven (21 views)
2014-07-23 21:07:15

Riven (24 views)
2014-07-23 20:56:16

ctomni231 (55 views)
2014-07-18 06:55:21

Zero Volt (47 views)
2014-07-17 23:47:54

danieldean (38 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

Cero (59 views)
2014-07-16 00:42:17

Riven (56 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!