--- a/modules/javafx.graphics/src/main/java/javafx/scene/Scene.java +++ b/modules/javafx.graphics/src/main/java/javafx/scene/Scene.java @@ -6249,6 +6252,18 @@ return getProperties().get(USER_DATA_KEY); } + final ScenePreferences preferences = new ScenePreferences(this); + + /** + * Gets the scene preferences that can override {@link Platform.Preferences platform} preferences. + * + * @return the {@code Preferences} instance + * @since 25 + */ + public final Preferences getPreferences() { + return preferences; + } + /* ************************************************************************* * * * Component Orientation Properties * @@ -6506,5 +6521,145 @@ } return accessible; } + + /** + * Contains scene preferences that can override {@link Platform.Preferences platform} preferences. + *

+ * All preferences are null-coalesting properties: if set to {@code null} (using the setter method, + * {@link Property#setValue(Object)}, or with a binding), the property evalutes to the value of the corresponding + * platform-provided preference. Likewise, specifying a non-null value for any given property will override the + * platform-provided value. + * + * @see Platform.Preferences + * @since 25 + */ + public sealed interface Preferences permits ScenePreferences { + + /** + * Specifies whether applications should always show scroll bars. If set to {@code false}, applications + * may choose to hide scroll bars that are not actively used, or make them smaller or less noticeable. + * + * @return the {@code persistentScrollBars} property + * @defaultValue {@link Platform.Preferences#isPersistentScrollBars()} + * @see Platform.Preferences#persistentScrollBarsProperty() + */ + ObjectProperty persistentScrollBarsProperty(); + + /** + * Gets the value of the {@code persistentScrollBars} property. + * + * @return the value of the {@code persistentScrollBars} property + * @see #persistentScrollBarsProperty() + * @see #setPersistentScrollBars(Boolean) + */ + boolean isPersistentScrollBars(); + + /** + * Sets the value of the {@code persistentScrollBars} property. + * + * @param value the value + * @see #persistentScrollBarsProperty() + * @see #isPersistentScrollBars() + */ + void setPersistentScrollBars(Boolean value); + + /** + * Specifies whether the scene should minimize the amount of non-essential animations, + * reducing discomfort for users who experience motion sickness or vertigo. + * + * @return the {@code reducedMotion} property + * @defaultValue {@link Platform.Preferences#isReducedMotion()} + * @see Platform.Preferences#reducedMotionProperty() + */ + ObjectProperty reducedMotionProperty(); + + /** + * Gets the value of the {@code reducedMotion} property. + * + * @return the value of the {@code reducedMotion} property + * @see #reducedMotionProperty() + * @see #setReducedMotion(Boolean) + */ + boolean isReducedMotion(); + + /** + * Sets the value of the {@code reducedMotion} property. + * + * @param value the value + * @see #reducedMotionProperty() + * @see #isReducedMotion() + */ + void setReducedMotion(Boolean value); + + /** + * Specifies whether the scene should minimize the amount of transparent or translucent + * layer effects, which can help to increase contrast and readability for some users. + * + * @return the {@code reducedTransparency} property + * @defaultValue {@link Platform.Preferences#isReducedTransparency()} + * @see Platform.Preferences#reducedTransparencyProperty() + */ + ObjectProperty reducedTransparencyProperty(); + + /** + * Gets the value of the {@code reducedTransparency} property. + * + * @return the value of the {@code reducedTransparency} property + * @see #reducedTransparencyProperty() + * @see #setReducedTransparency(Boolean) + */ + boolean isReducedTransparency(); + + /** + * Sets the value of the {@code reducedTransparency} property. + * + * @param value the value + * @see #reducedTransparencyProperty() + * @see #isReducedTransparency() + */ + void setReducedTransparency(Boolean value); + + /** + * Specifies whether the scene should minimize the amount of internet traffic, which users + * might request because they are on a metered network or a limited data plan. + * + * @return the {@code reducedData} property + * @defaultValue {@link Platform.Preferences#isReducedData()} + * @see Platform.Preferences#reducedDataProperty() + */ + ObjectProperty reducedDataProperty(); + + /** + * Gets the value of the {@code reducedData} property. + * + * @return the value of the {@code reducedData} property + * @see #reducedDataProperty() + * @see #setReducedData(Boolean) + */ + boolean isReducedData(); + + /** + * Sets the value of the {@code reducedData} property. + * + * @param value the value + * @see #reducedDataProperty() + * @see #isReducedData() + */ + void setReducedData(Boolean value); + + /** + * Specifies whether the scene should prefer light text on dark backgrounds, or dark text + * on light backgrounds. + * + * @return the {@code colorScheme} property + * @defaultValue {@link Platform.Preferences#getColorScheme()} + * @see Platform.Preferences#colorSchemeProperty() + */ + ObjectProperty colorSchemeProperty(); + + ColorScheme getColorScheme(); + + void setColorScheme(ColorScheme colorScheme); + } } --- a/modules/javafx.graphics/src/main/java/javafx/application/Platform.java +++ b/modules/javafx.graphics/src/main/java/javafx/application/Platform.java @@ -613,7 +613,17 @@ * 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. *

- * If the platform does not report this preference, this property defaults to {@code false}. + * This property corresponds to the following CSS media feature: + * + * + * + * + * + * + * + * + * + *
Media Feature
Name-fx-prefers-persistent-scrollbars
Valueno-preference | persistent
Boolean Contextno-preference evaluates as false
* * @return the {@code persistentScrollBars} property * @defaultValue {@code false} @@ -627,7 +637,17 @@ * Specifies whether applications should minimize the amount of non-essential animations, * reducing discomfort for users who experience motion sickness or vertigo. *

- * If the platform does not report this preference, this property defaults to {@code false}. + * This property corresponds to the following CSS media feature: + * + * + * + * + * + * + * + * + * + *
Media Feature
Nameprefers-reduced-motion
Valueno-preference | reduce
Boolean Contextno-preference evaluates as false
* * @return the {@code reducedMotion} property * @defaultValue {@code false} @@ -641,7 +661,17 @@ * Specifies whether applications should minimize the amount of transparent or translucent * layer effects, which can help to increase contrast and readability for some users. *

- * If the platform does not report this preference, this property defaults to {@code false}. + * This property corresponds to the following CSS media feature: + * + * + * + * + * + * + * + * + * + *
Media Feature
Nameprefers-reduced-transparency
Valueno-preference | reduce
Boolean Contextno-preference evaluates as false
* * @return the {@code reducedTransparency} property * @defaultValue {@code false} @@ -655,7 +685,17 @@ * 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. *

- * If the platform does not report this preference, this property defaults to {@code false}. + * This property corresponds to the following CSS media feature: + * + * + * + * + * + * + * + * + * + *
Media Feature
Nameprefers-reduced-data
Valueno-preference | reduce
Boolean Contextno-preference evaluates as false
* * @return the {@code reducedData} property * @defaultValue {@code false} @@ -669,7 +709,15 @@ * 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 {@code LIGHT}. + * This property corresponds to the following CSS media feature: + * + * + * + * + * + * + * + *
Media Feature
Nameprefers-color-scheme
Valuelight | dark
Boolean Contextnot applicable
* * @return the {@code colorScheme} property * @defaultValue {@link ColorScheme#LIGHT} @@ -680,8 +728,6 @@ /** * The color used for background regions. - *

- * If the platform does not report a background color, this property defaults to {@code WHITE}. * * @return the {@code backgroundColor} property * @defaultValue {@link Color#WHITE} @@ -692,8 +738,6 @@ /** * The color used for foreground elements like text. - *

- * If the platform does not report a foreground color, this property defaults to {@code BLACK}. * * @return the {@code foregroundColor} property * @defaultValue {@link Color#BLACK} @@ -706,9 +750,6 @@ * 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 {@code #157EFB}). * * @return the {@code accentColor} property * @defaultValue {@code #157EFB} --- a/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html +++ b/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html @@ -777,9 +777,10 @@

@ Rules

+

@import

Beginning with JavaFX 8u20, the CSS - @import is also partially supported. + @import is partially supported. Only unconditional import is supported. In other words, the media‑type qualifier is not supported. Also, the JavaFX CSS parser is non-compliant with regard to where an @import may appear within a stylesheet (see At‑rules). @@ -785,6 +786,7 @@ (see At‑rules). Users are cautioned that this will be fixed in a future release. Adherence to the W3C standard is strongly advised.

+

@font-face

Since JavaFX 8, the implementation partially supports the CSS3 syntax to load a font from a URL using the @font‑face rule: