From 90b5ded91f0f0b530a74da55bac81fc4ee8fd904 Mon Sep 17 00:00:00 2001 From: mkpaz Date: Thu, 9 Feb 2023 13:29:04 +0400 Subject: [PATCH] Use transparent background for code viewer (WebView) JavaFX 18 feature --- .../src/main/java/atlantafx/sampler/page/CodeViewer.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sampler/src/main/java/atlantafx/sampler/page/CodeViewer.java b/sampler/src/main/java/atlantafx/sampler/page/CodeViewer.java index 36966c5..03d85b8 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/CodeViewer.java +++ b/sampler/src/main/java/atlantafx/sampler/page/CodeViewer.java @@ -6,6 +6,7 @@ import atlantafx.sampler.theme.HighlightJSTheme; import atlantafx.sampler.util.Containers; import javafx.geometry.Insets; import javafx.scene.layout.AnchorPane; +import javafx.scene.paint.Color; import javafx.scene.web.WebView; import java.io.IOException; @@ -52,10 +53,7 @@ public class CodeViewer extends AnchorPane { .append("") .append("") .append("") - // Transparent background is allowed starting from OpenJFX 18. - // https://bugs.openjdk.org/browse/JDK-8090547 - // Until that it should match Highlight JS background. - .append(String.format("", theme.getBackground())) + .append("") .append("
")
                     .append("")
                     .append(new String(source.readAllBytes(), UTF_8))
@@ -65,6 +63,7 @@ public class CodeViewer extends AnchorPane {
                     .append("")
                     .toString();
 
+            webView.setPageFill(Color.TRANSPARENT);
             webView.getEngine().loadContent(content);
         } catch (IOException e) {
             throw new RuntimeException(e);