JEP 272: Platform-Specific Desktop Features

OwnerAlexander Zvegintsev
Created2014/06/30 15:52
Updated2017/06/28 15:03
StatusClosed / Delivered
Componentclient-libs / java.awt
Discussionawt dash dev at openjdk dot java dot net
Reviewed byPetr Pchelko, Sergey Bylokhov
Endorsed byKevin Rushforth


Define a new public API to access platform-specific desktop features such as interacting with a task bar or dock, or listening for system or application events.


In the forthcoming release of JDK 9, internal APIs such as those in the Mac OS X package will no longer be accessible. The goal of this JEP is to provide suitable replacements for these inaccessible APIs and, also, introduce related platform-specific features. We plan to implement the new features on those platforms that have the necessary support. Where feasible, the API will be designed to be cross-platform so that each feature can be implemented on as wide a range of platforms as possible. apple.applescript classes are being removed without providing any replacement.


We do not intend to provide direct replacements for all of the internal OS X APIs present in JDK 8. Specifically, we will not provide a replacement for the package. Is it also not a goal to maintain compatibility with those internal APIs for which we do provide substitutes.


This JEP contains two sub-tasks:

Provide public API to replace the functionality in{eawt,eio}

The intent of this subtask is to avoid loss of functionality for OS X developers. We will provide replacements for the APIs in the JDK-internal and packages.

Provide access to similar features on other platforms

In addition to features specific to OS X, there are similar features that can be supported on other platforms, including Windows and Linux:

Support for these features will be determined by platform capabilities.


We propose to add the public API for these two sub-tasks to the existing java.awt.Desktop class. The target supported platforms are Mac OS X, Windows, Linux.

Proposed API sketch:

package java.awt;

public class Desktop {

    /* ... */

     * Adds sub-types of {@link AppEventListener} to listen for notifications
     * from the native system.
     * @param listener
     * @see AppForegroundListener
     * @see AppHiddenListener
     * @see AppReOpenedListener
     * @see AppScreenSleepListener
     * @see AppSystemSleepListener
     * @see AppUserSessionListener

    public void addAppEventListener(final AppEventListener listener) {}

     * Requests user attention to this application (usually through bouncing the Dock icon).
     * Critical requests will continue to bounce the Dock icon until the app is activated.
    public void requestUserAttention(final boolean critical) {}

     * Attaches the contents of the provided PopupMenu to the application's Dock icon.
    public void setDockMenu(final PopupMenu menu) {}

     * Changes this application's Dock icon to the provided image.
    public void setDockIconImage(final Image image) {}

     * Affixes a small system provided badge to this application's Dock icon. Usually a number.
    public void setDockIconBadge(final String badge) {}

     * Displays or hides a progress bar or other indicator in
     * the dock.
     * @see DockProgressState.NORMAL
     * @see DockProgressState.PAUSED
     * @see DockProgressState.ERROR
     * @see #setDockProgressValue
    public void setDockProgressState(int state) {}

     * Sets the progress bar's current value to {@code n}.
    public void setDockProgressValue(int n) {}

     * Tests whether a feature is supported on the current platform.

    public boolean isSupportedFeature(Feature f) {}

    /* ... */


Testing will be limited to additional manual tests written to use the new API. Tests will need to check whether the new features are supported on platforms where they are expected to be supported, and that they fail gracefully on platforms with no support.