diff --git a/app/src/main/java/com/oracle/javafx/scenebuilder/app/menubar/MenuBarController.java b/app/src/main/java/com/oracle/javafx/scenebuilder/app/menubar/MenuBarController.java index bb5817d45..c084dd91c 100644 --- a/app/src/main/java/com/oracle/javafx/scenebuilder/app/menubar/MenuBarController.java +++ b/app/src/main/java/com/oracle/javafx/scenebuilder/app/menubar/MenuBarController.java @@ -2343,6 +2343,8 @@ public boolean canPerform() { @Override public void perform() { GluonEditorController.getInstance().setGluonSwatch(gluonSwatch); + // After swatch changes, force theme update to refresh the content + documentWindowController.getEditorController().refreshTheme(); } @Override diff --git a/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/editor/EditorController.java b/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/editor/EditorController.java index 8b0ae0752..666f12da1 100644 --- a/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/editor/EditorController.java +++ b/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/editor/EditorController.java @@ -580,6 +580,16 @@ public ObservableValue themeProperty() { return themeProperty; } + /** + * Refresh the theme and related stylesheets in different + * places (content, preview, ...) + */ + public void refreshTheme() { + EditorPlatform.Theme currentTheme = getTheme(); + setTheme(null); + setTheme(currentTheme); + } + /** * * @return the list of scene style sheet used by this editor diff --git a/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/editor/panel/content/ContentPanelController.java b/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/editor/panel/content/ContentPanelController.java index 7ebc306c2..fb6951f10 100644 --- a/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/editor/panel/content/ContentPanelController.java +++ b/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/editor/panel/content/ContentPanelController.java @@ -1074,7 +1074,9 @@ private void themeDidChange() { if (contentGroup != null) { final EditorPlatform.Theme theme = getEditorController().getTheme(); List themeStylesheets = new ArrayList<>(EditorPlatform.getStylesheetsForTheme(theme)); - themeStylesheets.addAll(theme.getStylesheetURLs()); + if (theme != null) { + themeStylesheets.addAll(theme.getStylesheetURLs()); + } workspaceController.setThemeStylesheet(themeStylesheets, theme); } }