Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8301303

Allow Stage to control the appearance of window decorations

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • None
    • javafx
    • None

      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();

            mstrauss Michael Strauß
            mstrauss Michael Strauß
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: