JDK-8301303 : Allow Stage to control the appearance of window decorations
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: scenegraph
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2023-01-29
  • Updated: 2023-02-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Blocks :  
Description
A well-designed dark mode integration requires a JavaFX application to not only provide a set of suitable dark stylesheets, but also configure the platform window decorations to reflect the dark theme. This requires a new API to control the appearance of window decorations:

    public class Stage {
        ...
        public ObjectProperty<Appearance> appearanceProperty();
        public Appearance getAppearance();
        public void setAppearance(Appearance appearance);
        ...
    }

By default, a JavaFX stage uses a light appearance. Developers can set the stage appearance to either light or dark independently from the operating system's dark mode setting. This can be useful for applications that only offer either a light or a dark theme.
Applications that support both appearances and want to reflect the OS preference can do so by simply binding the stage appearance to the platform appearance:

    var stage = new Stage();
    stage.appearanceProperty().bind(
        Platform.getPreferences().appearanceProperty());

    stage.setScene(...);
    stage.show();