Skip to Main Content

Java SE (Java Platform, Standard Edition)

How to remove dock icon on Mac when main stage is hidden?

bvmAug 29 2012
I'm trying to implement a "minimize to system tray" functionality, where when the user closes the app's window, it disappears from the task bar and can be retrieved from the system tray. This works great on Windows and Linux, but on the Mac, the window closes, but the app's icon remains in the dock. Clicking on the dock icon focuses the app, but (perhaps unsurprisingly) does not open the window, which is a pretty bad user experience. Opening the window from the system tray works, so if I could just hide the dock icon I'd be there.

I found the undocumented PlatformImpl.setTaskbarApplication(false), but it doesn't seem to have any effect. Probably only does something at launch time.

Bug or feature?

(I'm using the new Platform.setImplicitExit(false) to keep the app from exiting when the main stage is hidden, but I see the same behavior when using the "create an off-screen dummy stage" kludge in 2.1.)
Post Details
Locked on Sep 26 2012
Added on Aug 29 2012