<AWT Dev> RFR: JDK-8194327 [macos] AWT windows have incorrect main/key window behaviors

Alan Snyder javalists at cbfiddle.com
Tue Apr 3 02:35:40 UTC 2018

Please review the following change to the macOS AWT.

Bug: https://bugs.openjdk.java.net/browse/JDK-8194327
Webrev: http://cr.openjdk.java.net/~serb/alans/8194327/webrev.00/

The goal of this change is to allow a Java desktop application on macOS to properly coexist with a native utility panel, such as the native color chooser.

The native color chooser is an example of a window that can become the key (focused) window but cannot become the main window.
If the previously active window is a Java frame, it should resign key window status (lose focus), but retain the main window status.
A window that is main but not key does not own the keyboard focus, but it appears active, and if it is using the screen menu bar,
it may be invoked to process a menu item action (if the menu item is not already handled by the key window).

The current macOS AWT does not support this combination of window states. A Java window is either key and main, or neither.
When the color chooser becomes key (obtains focus), the Java frame resigns both key and main status.

This change allows the key window status to be resigned while retaining the main window status, with the appropriate behavior.

Note that with this change, it remains impossible to implement a Java window that behaves like the native color chooser (i.e., can become key but not main).
That would require a much bigger change.


More information about the awt-dev mailing list