modules/graphics/src/main/java/com/sun/javafx/application/PlatformImpl.java
Print this page
@@ -535,10 +535,38 @@
} else {
runLater(() -> _setPlatformUserAgentStylesheet(stylesheetUrl));
}
}
+ private static String accessibilityTheme;
+ public static boolean setAccessibilityTheme(String themeName) {
+ if (accessibilityTheme != null) {
+ StyleManager.getInstance().removeUserAgentStylesheet(accessibilityTheme);
+ accessibilityTheme = null;
+ }
+ if (themeName == null) return false;
+ if(isModena) {
+ //pick the right one based on themeName
+ if (themeName.equals("High Contrast White")) {
+ accessibilityTheme = "com/sun/javafx/scene/control/skin/modena/whiteOnBlack.css";
+ } else if (themeName.equals("High Contrast #1")) {
+ accessibilityTheme = "com/sun/javafx/scene/control/skin/modena/yellowOnBlack.css";
+ } else if (themeName.equals("High Contrast Black")) {
+ accessibilityTheme = "com/sun/javafx/scene/control/skin/modena/blackOnWhite.css";
+ }
+ }
+ if (isCaspian) {
+ // caspian only has one high contrast theme
+ accessibilityTheme = "com/sun/javafx/scene/control/skin/caspian/highcontrast.css";
+ }
+ if (accessibilityTheme != null) {
+ StyleManager.getInstance().addUserAgentStylesheet(accessibilityTheme);
+ return true;
+ }
+ return false;
+ }
+
private static void _setPlatformUserAgentStylesheet(String stylesheetUrl) {
isModena = isCaspian = false;
// check for command line override
final String overrideStylesheetUrl = AccessController.doPrivileged(
(PrivilegedAction<String>) () -> System.getProperty("javafx.userAgentStylesheetUrl"));
@@ -621,10 +649,12 @@
}
}
} else {
StyleManager.getInstance().setDefaultUserAgentStylesheet(stylesheetUrl);
}
+ // Ensure that accessibility starts right
+ setAccessibilityTheme(Toolkit.getToolkit().getThemeName());
}
public static void addNoTransparencyStylesheetToScene(final Scene scene) {
if (PlatformImpl.isCaspian()) {
AccessController.doPrivileged((PrivilegedAction) () -> {