I looked through ApplicationListener, and they don’t have it in there. On a Mac, it’s when that application has the equivalent of focus; its menu is in the top menu bar.
Also, if you know this, could you tell me how my application can request to de-focus itself?
Implementations of
windowActivated()andwindowDeactivated()inWindowListenerorWindowAdapterwill tell you when a window is activated or deactivated. You don’t needApplicationListenerfor that.Addendum: Although not required in this case, a transparent implementation of the additional functionality specified in
ApplicationListenermay be found in this example.Addendum: See also How to Write Window Listeners.
Addendum: I think I see what you mean. In the example
OSXAdapter, which uses-Dapple.laf.useScreenMenuBar=true, the menus disappear when the last window (HIDE_ON_CLOSEby default) closes. It’s less than optimal, but theAbout…andPreferencesmenus remain in the application menu; choosing either restores the screen menu. Another possibility is to modify the dock menu incom.apple.eawt.Application.