Interface Platform.Preferences

All Superinterfaces:
Map<String,Object>, Observable, ObservableMap<String,Object>
Enclosing class:
Platform

public static interface Platform.Preferences extends ObservableMap<String,Object>
Contains UI preferences of the current platform.

Preferences extends ObservableMap to expose platform preferences as key-value pairs. The map is unmodifiable, which means that keys and values cannot be added, removed, or updated. Calling any mutator method on the map will always cause UnsupportedOperationException to be thrown. However, the mappings will be updated by JavaFX when the operating system reports that a platform preference has changed.

For convenience, getInteger(java.lang.String), getDouble(java.lang.String), getBoolean(java.lang.String), getString(java.lang.String), getColor(java.lang.String), and getValue(java.lang.String, java.lang.Class<T>) are provided as typed alternatives to the untyped Map.get(java.lang.Object) method.

The preferences that are reported by the platform may be dependent on the operating system version and its current configuration, so applications should not assume that a particular preference is always available.

The following preferences are potentially available on the specified platforms:

Windows
Windows.SPI.HighContrastBoolean
Windows.SPI.HighContrastColorSchemeString
Windows.SysColor.COLOR_3DFACEColor
Windows.SysColor.COLOR_BTNTEXTColor
Windows.SysColor.COLOR_GRAYTEXTColor
Windows.SysColor.COLOR_HIGHLIGHTColor
Windows.SysColor.COLOR_HIGHLIGHTTEXTColor
Windows.SysColor.COLOR_HOTLIGHTColor
Windows.SysColor.COLOR_WINDOWColor
Windows.SysColor.COLOR_WINDOWTEXTColor
Windows.UIColor.BackgroundColor
Windows.UIColor.ForegroundColor
Windows.UIColor.AccentDark3Color
Windows.UIColor.AccentDark2Color
Windows.UIColor.AccentDark1Color
Windows.UIColor.AccentColor
Windows.UIColor.AccentLight1Color
Windows.UIColor.AccentLight2Color
Windows.UIColor.AccentLight3Color
macOS
macOS.NSColor.labelColorColor
macOS.NSColor.secondaryLabelColorColor
macOS.NSColor.tertiaryLabelColorColor
macOS.NSColor.quaternaryLabelColorColor
macOS.NSColor.textColorColor
macOS.NSColor.placeholderTextColorColor
macOS.NSColor.selectedTextColorColor
macOS.NSColor.textBackgroundColorColor
macOS.NSColor.selectedTextBackgroundColorColor
macOS.NSColor.keyboardFocusIndicatorColorColor
macOS.NSColor.unemphasizedSelectedTextColorColor
macOS.NSColor.unemphasizedSelectedTextBackgroundColorColor
macOS.NSColor.linkColorColor
macOS.NSColor.separatorColorColor
macOS.NSColor.selectedContentBackgroundColorColor
macOS.NSColor.unemphasizedSelectedContentBackgroundColorColor
macOS.NSColor.selectedMenuItemTextColorColor
macOS.NSColor.gridColorColor
macOS.NSColor.headerTextColorColor
macOS.NSColor.alternatingContentBackgroundColorsColor[]
macOS.NSColor.controlAccentColorColor
macOS.NSColor.controlColorColor
macOS.NSColor.controlBackgroundColorColor
macOS.NSColor.controlTextColorColor
macOS.NSColor.disabledControlTextColorColor
macOS.NSColor.selectedControlColorColor
macOS.NSColor.selectedControlTextColorColor
macOS.NSColor.alternateSelectedControlTextColorColor
macOS.NSColor.currentControlTintString
macOS.NSColor.windowBackgroundColorColor
macOS.NSColor.windowFrameTextColorColor
macOS.NSColor.underPageBackgroundColorColor
macOS.NSColor.findHighlightColorColor
macOS.NSColor.highlightColorColor
macOS.NSColor.shadowColorColor
macOS.NSColor.systemBlueColorColor
macOS.NSColor.systemBrownColorColor
macOS.NSColor.systemGrayColorColor
macOS.NSColor.systemGreenColorColor
macOS.NSColor.systemIndigoColorColor
macOS.NSColor.systemOrangeColorColor
macOS.NSColor.systemPinkColorColor
macOS.NSColor.systemPurpleColorColor
macOS.NSColor.systemRedColorColor
macOS.NSColor.systemTealColorColor
macOS.NSColor.systemYellowColorColor
Linux
GTK.theme_nameString
GTK.theme_fg_colorColor
GTK.theme_bg_colorColor
GTK.theme_base_colorColor
GTK.theme_selected_bg_colorColor
GTK.theme_selected_fg_colorColor
GTK.theme_unfocused_fg_colorColor
GTK.theme_unfocused_bg_colorColor
GTK.theme_unfocused_base_colorColor
GTK.theme_unfocused_selected_bg_colorColor
GTK.theme_unfocused_selected_fg_colorColor
GTK.insensitive_bg_colorColor
GTK.insensitive_fg_colorColor
GTK.insensitive_base_colorColor
GTK.bordersColor
GTK.unfocused_bordersColor
GTK.warning_colorColor
GTK.error_colorColor
GTK.success_colorColor
Since:
22
  • Property Details

  • Method Details

    • colorSchemeProperty

      ReadOnlyObjectProperty<ColorScheme> colorSchemeProperty()
      The platform color scheme, which specifies whether applications should prefer light text on dark backgrounds, or dark text on light backgrounds.

      If the platform does not report color preferences, this property defaults to LIGHT.

      Default value:
      ColorScheme.LIGHT
      Returns:
      the colorScheme property
      See Also:
    • getColorScheme

      ColorScheme getColorScheme()
      Gets the value of the colorScheme property.
      Property description:
      The platform color scheme, which specifies whether applications should prefer light text on dark backgrounds, or dark text on light backgrounds.

      If the platform does not report color preferences, this property defaults to LIGHT.

      Default value:
      ColorScheme.LIGHT
      Returns:
      the value of the colorScheme property
      See Also:
    • backgroundColorProperty

      ReadOnlyObjectProperty<Color> backgroundColorProperty()
      The color used for background regions.

      If the platform does not report a background color, this property defaults to WHITE.

      Default value:
      Color.WHITE
      Returns:
      the backgroundColor property
      See Also:
    • getBackgroundColor

      Color getBackgroundColor()
      Gets the value of the backgroundColor property.
      Property description:
      The color used for background regions.

      If the platform does not report a background color, this property defaults to WHITE.

      Default value:
      Color.WHITE
      Returns:
      the value of the backgroundColor property
      See Also:
    • foregroundColorProperty

      ReadOnlyObjectProperty<Color> foregroundColorProperty()
      The color used for foreground elements like text.

      If the platform does not report a foreground color, this property defaults to BLACK.

      Default value:
      Color.BLACK
      Returns:
      the foregroundColor property
      See Also:
    • getForegroundColor

      Color getForegroundColor()
      Gets the value of the foregroundColor property.
      Property description:
      The color used for foreground elements like text.

      If the platform does not report a foreground color, this property defaults to BLACK.

      Default value:
      Color.BLACK
      Returns:
      the value of the foregroundColor property
      See Also:
    • accentColorProperty

      ReadOnlyObjectProperty<Color> accentColorProperty()
      The accent color, which can be used to highlight the active or important part of a control and make it stand out from the rest of the user interface. It is usually a vivid color that contrasts with the foreground and background colors.

      If the platform does not report an accent color, this property defaults to vivid blue (corresponding to the hex color value #157EFB).

      Default value:
      #157EFB
      Returns:
      the accentColor property
      See Also:
    • getAccentColor

      Color getAccentColor()
      Gets the value of the accentColor property.
      Property description:
      The accent color, which can be used to highlight the active or important part of a control and make it stand out from the rest of the user interface. It is usually a vivid color that contrasts with the foreground and background colors.

      If the platform does not report an accent color, this property defaults to vivid blue (corresponding to the hex color value #157EFB).

      Default value:
      #157EFB
      Returns:
      the value of the accentColor property
      See Also:
    • getInteger

      Optional<Integer> getInteger(String key)
      Returns an optional Integer to which the specified key is mapped.
      Parameters:
      key - the key
      Returns:
      the optional Integer to which the key is mapped
      Throws:
      NullPointerException - if key is null
      IllegalArgumentException - if the key is not mappable to an Integer
    • getDouble

      Optional<Double> getDouble(String key)
      Returns an optional Double to which the specified key is mapped.
      Parameters:
      key - the key
      Returns:
      the optional Double to which the key is mapped
      Throws:
      NullPointerException - if key is null
      IllegalArgumentException - if the key is not mappable to a Double
    • getBoolean

      Optional<Boolean> getBoolean(String key)
      Returns an optional Boolean to which the specified key is mapped.
      Parameters:
      key - the key
      Returns:
      the optional Boolean to which the key is mapped
      Throws:
      NullPointerException - if key is null
      IllegalArgumentException - if the key is not mappable to a Boolean
    • getString

      Optional<String> getString(String key)
      Returns an optional String to which the specified key is mapped.
      Parameters:
      key - the key
      Returns:
      the optional String to which the key is mapped
      Throws:
      NullPointerException - if key is null
      IllegalArgumentException - if the key is not mappable to a String
    • getColor

      Optional<Color> getColor(String key)
      Returns an optional Color to which the specified key is mapped.
      Parameters:
      key - the key
      Returns:
      the optional Color instance to which the key is mapped
      Throws:
      NullPointerException - if key is null
      IllegalArgumentException - if the key is not mappable to a Color
    • getValue

      <T> Optional<T> getValue(String key, Class<T> type)
      Returns an optional value to which the specified key is mapped.
      Type Parameters:
      T - the type of the value
      Parameters:
      key - the key
      type - the type of the value
      Returns:
      the optional value to which the key is mapped
      Throws:
      NullPointerException - if key or type is null
      IllegalArgumentException - if the key is not mappable to a value of type T