I’ve released a new version of my long-running password keeper application: JPasskeep. This new release is now able to handle a Command-Q keystroke on the Mac, giving a user (i.e. me) an chance to save any updated entries. No more mousing around to close a window.
The actual mechanism to do this was to reflectively call Apple’s EAWT application classes to allow me to register the correct event listener. Hmm, run anywhere with java GUI apps.
You can download the cross-platform and mac DMG binaries from the project’s GitHub repository.
#1 by Robert on 7 February 2010 - 2:15 pm
Quote
I’m not 100% positive, but I think it may be because you’re not constructing your own menu – thus getting the default menus.
If you had your own menu, with your own Quit command, that would probably be truly cross-platform.
#2 by Tom on 7 February 2010 - 7:24 pm
Quote
Thanks Robert. I do actually get a JPasskeep screen menu on Mac with a quit option and Command-Q as its shortcut, its just that I chose to keep the application menu with the window and not at the top of the screen. I could create my own Quit menu option, but it does seem a little redundant.
If exiting the window on Windows (by closing the window or Alt-F4) kicks in the window closing event, why does that not happen on Macs? That’s what I wanted to figure out and it seems like a difference in java between Mac and everyone else.
#3 by Robert on 8 February 2010 - 9:44 am
Quote
A slight misunderstanding in the event model, I guess.
Alt-F4 is not Quit, in Windows. It’s “Close Window”. It just happens that the app is coded to quit when the last window closes. The corresponding shortcut on the Mac is Cmd-W.
OTH – lots of Windows users probably think of Alt-F4 as “Quit”.
#4 by Tom on 8 February 2010 - 10:29 am
Quote
Ok, now I get it. On Macs closing the last window does not equal shutting down the application, which is why I get those neat little lights under running apps in the taskbar without any open windows.