Mailing Lists: Apple Mailing Lists

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

How to detect when the application loses or takes focus



Hi,

I have an application that uses palettes. These are created using JWindows that are owned by JFrames. When the application loses focus (e.g. when I click on the Finder) I want to hide all of my palettes. Likewise, I want to show my palettes when my application regains focus (e.g. click on one of its windows or click on its icon in the dock). The behaviour will then be consistent with other applications (Pages, Photoshop etc).

Is the best way to just watch for WindowEvents and (using getOppositeWindow()) establish that if the oppositeWindow is null that the application is either losing or taking focus. I'm using and targetting Java 1.4.2.

Or is there a better/easier way?

Best regards,

Ian Cheyne
_______________________________________________
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


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.