APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.javafx.application.preferences

public final Class PlatformPreferences

extends AbstractMap<String, Object>
implements Preferences
Class Inheritance
All Implemented Interfaces
javafx.application.Platform.Preferences, javafx.collections.ObservableMap, javafx.beans.Observable, java.util.Map
Imports
com.sun.javafx.binding.MapExpressionHelper, javafx.application.ColorScheme, .Platform, javafx.beans.InvalidationListener, javafx.beans.property.ReadOnlyBooleanProperty, .ReadOnlyObjectProperty, javafx.collections.MapChangeListener, javafx.scene.paint.Color, java.io.Serializable, java.lang.reflect.Modifier, java.util.AbstractMap, .Collections, .HashMap, .List, .Map, .Set, .Objects, .Optional, java.util.concurrent.CopyOnWriteArrayList

Contains the implementation of a read-only map of platform preferences.

When the operating system signals that a preference has changed, the mappings are updated by calling the update(Map) method.

Field Summary

Modifier and TypeField and Description
private final Map<String, Object>
effectivePreferences

Contains the current set of effective preferences, i.e. the set of preferences that we know to be the current state of the world, and are exposed to users of this map.

private final List<InvalidationListener>
private final List<MapChangeListener<? super String, Object>>
private final Map<String, PreferenceMapping<?, ?>>
platformKeyMappings

Contains mappings from platform-specific keys to well-known keys, which are used in the implementation of the property-based API in PreferenceProperties.

private final Map<String, Class<?>>
platformKeys

Contains mappings from platform-specific keys to their types.

private final PreferenceProperties
properties

Contains the implementation of the property-based API.

private final Map<String, Object>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ReadOnlyObjectProperty<Color>
accentColorProperty()

Implements javafx.application.Platform.Preferences.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.

public void
addListener(InvalidationListener listener)

Implements javafx.beans.Observable.addListener.

Adds an InvalidationListener which will be notified whenever the Observable becomes invalid.

public void
addListener(MapChangeListener<? super String, ? super Object> listener)

Implements javafx.collections.ObservableMap.addListener.

Add a listener to this observable map.

public ReadOnlyObjectProperty<Color>
public ReadOnlyObjectProperty<ColorScheme>
colorSchemeProperty()

Implements javafx.application.Platform.Preferences.colorSchemeProperty.

The platform color scheme, which specifies whether applications should prefer light text on dark backgrounds, or dark text on light backgrounds.

public Set<Map.Entry<String, Object>>
entrySet()

Implements abstract java.util.AbstractMap.entrySet.

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.

private void
public ReadOnlyObjectProperty<Color>
foregroundColorProperty()

Implements javafx.application.Platform.Preferences.foregroundColorProperty.

The color used for foreground elements like text.

public Color
public Color
public Optional<Boolean>
getBoolean(String key)

Implements javafx.application.Platform.Preferences.getBoolean.

Returns an optional Boolean to which the specified key is mapped.

public Optional<Color>
getColor(String key)

Implements javafx.application.Platform.Preferences.getColor.

Returns an optional Color to which the specified key is mapped.

public ColorScheme
public Optional<Double>
getDouble(String key)

Implements javafx.application.Platform.Preferences.getDouble.

Returns an optional Double to which the specified key is mapped.

public Color
public Optional<Integer>
getInteger(String key)

Implements javafx.application.Platform.Preferences.getInteger.

Returns an optional Integer to which the specified key is mapped.

public Optional<String>
getString(String key)

Implements javafx.application.Platform.Preferences.getString.

Returns an optional String to which the specified key is mapped.

public <T> Optional<T>
getValue(String key, Class<T> type)

Implements javafx.application.Platform.Preferences.getValue.

Returns an optional value to which the specified key is mapped.

public void
initialize(Map<String, Class<?>>
the platform-specific keys and the types of their values
platformKeys
,
Map<String, PreferenceMapping<?, ?>>
the platform-specific key mappings
platformKeyMappings
)

Initializes this PlatformPreferences instance with the given platform-specific keys and key mappings.

private boolean
isArrayConvertible(Class<?> source, Class<?> target)

private boolean
isClassConvertible(Class<?> source, Class<?> target)

private boolean

Returns:

true if a casting conversion exists, false otherwise
isConvertible
(Class<?>
the source type
source
,
Class<?>
the target type
target
)

Determines whether a compile-time casting conversion exists from source to target.

private boolean
isInterfaceConvertible(Class<?> source, Class<?> target)

public boolean
public boolean
public boolean
public boolean
public ReadOnlyBooleanProperty
persistentScrollBarsProperty()

Implements javafx.application.Platform.Preferences.persistentScrollBarsProperty.

Specifies whether applications should always show scroll bars.

public ReadOnlyBooleanProperty
reducedDataProperty()

Implements javafx.application.Platform.Preferences.reducedDataProperty.

Specifies whether applications should minimize the amount of internet traffic, which users might request because they are on a metered network or a limited data plan.

public ReadOnlyBooleanProperty
reducedMotionProperty()

Implements javafx.application.Platform.Preferences.reducedMotionProperty.

Specifies whether applications should minimize the amount of non-essential animations, reducing discomfort for users who experience motion sickness or vertigo.

public ReadOnlyBooleanProperty
reducedTransparencyProperty()

Implements javafx.application.Platform.Preferences.reducedTransparencyProperty.

Specifies whether applications should minimize the amount of transparent or translucent layer effects, which can help to increase contrast and readability for some users.

public Object
remove(Object key)

Overrides java.util.AbstractMap.remove.

Implements java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation).

public void
removeListener(InvalidationListener listener)

Implements javafx.beans.Observable.removeListener.

Removes the given listener from the list of listeners, that are notified whenever the value of the Observable becomes invalid.

public void
removeListener(MapChangeListener<? super String, ? super Object> listener)

Implements javafx.collections.ObservableMap.removeListener.

Tries to removed a listener from this observable map.

public void
update(Map<String, Object>
the new preference mappings
preferences
)

Updates this map of preferences with a new set of platform preferences.

Inherited from java.util.AbstractMap:
clearclonecontainsKeycontainsValueequalsgethashCodeisEmptykeySetputputAllsizetoStringvalues

Field Detail

effectivePreferencesback to summary
private final Map<String, Object> effectivePreferences

Contains the current set of effective preferences, i.e. the set of preferences that we know to be the current state of the world, and are exposed to users of this map.

invalidationListenersback to summary
private final List<InvalidationListener> invalidationListeners
mapChangeListenersback to summary
private final List<MapChangeListener<? super String, Object>> mapChangeListeners
platformKeyMappingsback to summary
private final Map<String, PreferenceMapping<?, ?>> platformKeyMappings

Contains mappings from platform-specific keys to well-known keys, which are used in the implementation of the property-based API in PreferenceProperties.

platformKeysback to summary
private final Map<String, Class<?>> platformKeys

Contains mappings from platform-specific keys to their types. This information is used to catch misuse of typed getters even if the preferences map doesn't contain the preference mapping at runtime.

propertiesback to summary
private final PreferenceProperties properties

Contains the implementation of the property-based API.

unmodifiableEffectivePreferencesback to summary
private final Map<String, Object> unmodifiableEffectivePreferences

Constructor Detail

PlatformPreferencesback to summary
public PlatformPreferences()

Method Detail

accentColorPropertyback to summary
public ReadOnlyObjectProperty<Color> accentColorProperty()

Implements javafx.application.Platform.Preferences.accentColorProperty.

Doc from javafx.application.Platform.Preferences.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.

Annotations
@Override
addListenerback to summary
public void addListener(InvalidationListener listener)

Implements javafx.beans.Observable.addListener.

Doc from javafx.beans.Observable.addListener.

Adds an InvalidationListener which will be notified whenever the Observable becomes invalid. If the same listener is added more than once, then it will be notified more than once. That is, no check is made to ensure uniqueness.

Note that the same actual InvalidationListener instance may be safely registered for different Observables.

The Observable stores a strong reference to the listener which will prevent the listener from being garbage collected and may result in a memory leak. It is recommended to either unregister a listener by calling removeListener after use or to use an instance of WeakInvalidationListener avoid this situation.

Annotations
@Override
addListenerback to summary
public void addListener(MapChangeListener<? super String, ? super Object> listener)

Implements javafx.collections.ObservableMap.addListener.

Doc from javafx.collections.ObservableMap.addListener.

Add a listener to this observable map.

Annotations
@Override
backgroundColorPropertyback to summary
public ReadOnlyObjectProperty<Color> backgroundColorProperty()

Implements javafx.application.Platform.Preferences.backgroundColorProperty.

Doc from javafx.application.Platform.Preferences.backgroundColorProperty.

The color used for background regions.

Annotations
@Override
colorSchemePropertyback to summary
public ReadOnlyObjectProperty<ColorScheme> colorSchemeProperty()

Implements javafx.application.Platform.Preferences.colorSchemeProperty.

Doc from javafx.application.Platform.Preferences.colorSchemeProperty.

The platform color scheme, which specifies whether applications should prefer light text on dark backgrounds, or dark text on light backgrounds.

This property corresponds to the prefers-color-scheme media feature.

Annotations
@Override
entrySetback to summary
public Set<Map.Entry<String, Object>> entrySet()

Implements abstract java.util.AbstractMap.entrySet.

Implements java.util.Map.entrySet.

Doc from java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

Annotations
@Override
fireValueChangedEventback to summary
private void fireValueChangedEvent(Map<String, ChangedValue> changedEntries)
foregroundColorPropertyback to summary
public ReadOnlyObjectProperty<Color> foregroundColorProperty()

Implements javafx.application.Platform.Preferences.foregroundColorProperty.

Doc from javafx.application.Platform.Preferences.foregroundColorProperty.

The color used for foreground elements like text.

Annotations
@Override
getAccentColorback to summary
public Color getAccentColor()

Implements javafx.application.Platform.Preferences.getAccentColor.

Annotations
@Override
getBackgroundColorback to summary
public Color getBackgroundColor()

Implements javafx.application.Platform.Preferences.getBackgroundColor.

Annotations
@Override
getBooleanback to summary
public Optional<Boolean> getBoolean(String key)

Implements javafx.application.Platform.Preferences.getBoolean.

Doc from javafx.application.Platform.Preferences.getBoolean.

Returns an optional Boolean to which the specified key is mapped.

Annotations
@Override
getColorback to summary
public Optional<Color> getColor(String key)

Implements javafx.application.Platform.Preferences.getColor.

Doc from javafx.application.Platform.Preferences.getColor.

Returns an optional Color to which the specified key is mapped.

Annotations
@Override
getColorSchemeback to summary
public ColorScheme getColorScheme()

Implements javafx.application.Platform.Preferences.getColorScheme.

Annotations
@Override
getDoubleback to summary
public Optional<Double> getDouble(String key)

Implements javafx.application.Platform.Preferences.getDouble.

Doc from javafx.application.Platform.Preferences.getDouble.

Returns an optional Double to which the specified key is mapped.

Annotations
@Override
getForegroundColorback to summary
public Color getForegroundColor()

Implements javafx.application.Platform.Preferences.getForegroundColor.

Annotations
@Override
getIntegerback to summary
public Optional<Integer> getInteger(String key)

Implements javafx.application.Platform.Preferences.getInteger.

Doc from javafx.application.Platform.Preferences.getInteger.

Returns an optional Integer to which the specified key is mapped.

Annotations
@Override
getStringback to summary
public Optional<String> getString(String key)

Implements javafx.application.Platform.Preferences.getString.

Doc from javafx.application.Platform.Preferences.getString.

Returns an optional String to which the specified key is mapped.

Annotations
@Override
getValueback to summary
public <T> Optional<T> getValue(String key, Class<T> type)

Implements javafx.application.Platform.Preferences.getValue.

Doc from javafx.application.Platform.Preferences.getValue.

Returns an optional value to which the specified key is mapped.

Annotations
@Override
initializeback to summary
public void initialize(Map<String, Class<?>> platformKeys, Map<String, PreferenceMapping<?, ?>> platformKeyMappings)

Initializes this PlatformPreferences instance with the given platform-specific keys and key mappings.

Parameters
platformKeys:Map<String, Class<?>>

the platform-specific keys and the types of their values

platformKeyMappings:Map<String, PreferenceMapping<?, ?>>

the platform-specific key mappings

Exceptions
NullPointerException:
if platformKeys or platformKeyMappings is null or contains null keys or values
isArrayConvertibleback to summary
private boolean isArrayConvertible(Class<?> source, Class<?> target)
isClassConvertibleback to summary
private boolean isClassConvertible(Class<?> source, Class<?> target)
isConvertibleback to summary
private boolean isConvertible(Class<?> source, Class<?> target)

Determines whether a compile-time casting conversion exists from source to target. This is an implementation of JLS 5.5.1 (Reference Type Casting).

Parameters
source:Class<?>

the source type

target:Class<?>

the target type

Returns:boolean

true if a casting conversion exists, false otherwise

isInterfaceConvertibleback to summary
private boolean isInterfaceConvertible(Class<?> source, Class<?> target)
isPersistentScrollBarsback to summary
public boolean isPersistentScrollBars()

Implements javafx.application.Platform.Preferences.isPersistentScrollBars.

Annotations
@Override
isReducedDataback to summary
public boolean isReducedData()

Implements javafx.application.Platform.Preferences.isReducedData.

Annotations
@Override
isReducedMotionback to summary
public boolean isReducedMotion()

Implements javafx.application.Platform.Preferences.isReducedMotion.

Annotations
@Override
isReducedTransparencyback to summary
public boolean isReducedTransparency()

Implements javafx.application.Platform.Preferences.isReducedTransparency.

Annotations
@Override
persistentScrollBarsPropertyback to summary
public ReadOnlyBooleanProperty persistentScrollBarsProperty()

Implements javafx.application.Platform.Preferences.persistentScrollBarsProperty.

Doc from javafx.application.Platform.Preferences.persistentScrollBarsProperty.

Specifies whether applications should always show scroll bars. If not set, an application may choose to hide scroll bars that are not actively used, or make them smaller or less noticeable.

This property corresponds to the -fx-prefers-persistent-scrollbars media feature.

Annotations
@Override
reducedDataPropertyback to summary
public ReadOnlyBooleanProperty reducedDataProperty()

Implements javafx.application.Platform.Preferences.reducedDataProperty.

Doc from javafx.application.Platform.Preferences.reducedDataProperty.

Specifies whether applications should minimize the amount of internet traffic, which users might request because they are on a metered network or a limited data plan.

This property corresponds to the prefers-reduced-data media feature.

Annotations
@Override
reducedMotionPropertyback to summary
public ReadOnlyBooleanProperty reducedMotionProperty()

Implements javafx.application.Platform.Preferences.reducedMotionProperty.

Doc from javafx.application.Platform.Preferences.reducedMotionProperty.

Specifies whether applications should minimize the amount of non-essential animations, reducing discomfort for users who experience motion sickness or vertigo.

This property corresponds to the prefers-reduced-motion media feature.

Annotations
@Override
reducedTransparencyPropertyback to summary
public ReadOnlyBooleanProperty reducedTransparencyProperty()

Implements javafx.application.Platform.Preferences.reducedTransparencyProperty.

Doc from javafx.application.Platform.Preferences.reducedTransparencyProperty.

Specifies whether applications should minimize the amount of transparent or translucent layer effects, which can help to increase contrast and readability for some users.

This property corresponds to the prefers-reduced-transparency media feature.

Annotations
@Override
removeback to summary
public Object remove(Object key)

Overrides java.util.AbstractMap.remove.

Implements java.util.Map.remove.

Doc from java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation). More formally, if this map contains a mapping from key k to value v such that Objects.equals(key, k), that mapping is removed. (The map can contain at most one such mapping.)

Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.

If this map permits null values, then a return value of null does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to null.

The map will not contain a mapping for the specified key once the call returns.

Annotations
@Override
removeListenerback to summary
public void removeListener(InvalidationListener listener)

Implements javafx.beans.Observable.removeListener.

Doc from javafx.beans.Observable.removeListener.

Removes the given listener from the list of listeners, that are notified whenever the value of the Observable becomes invalid.

If the given listener has not been previously registered (i.e. it was never added) then this method call is a no-op. If it had been previously added then it will be removed. If it had been added more than once, then only the first occurrence will be removed.

Annotations
@Override
removeListenerback to summary
public void removeListener(MapChangeListener<? super String, ? super Object> listener)

Implements javafx.collections.ObservableMap.removeListener.

Doc from javafx.collections.ObservableMap.removeListener.

Tries to removed a listener from this observable map. If the listener is not attached to this map, nothing happens.

Annotations
@Override
updateback to summary
public void update(Map<String, Object> preferences)

Updates this map of preferences with a new set of platform preferences. The specified preferences may include all available preferences, or only the changed preferences. The absence of a mapping in the specified preferences does not indicate that it should be removed; instead, a key must be explicitly mapped to null to remove the mapping. Consequently, this map will never contain null values.

Parameters
preferences:Map<String, Object>

the new preference mappings

Exceptions
NullPointerException:
if preferences is null