in my JavaApplication I have a JLayeredPane in my JFrame. The JLayeredPane contains a Canvas as a lower panel where I display a Video with a videoplayer framework. On an upper level the JLayeredPane contains an JFXPanel where I display a JavaFX.WebView. The Webview is complete transparent.
The problem is that the Canvas is only visible where the WebView is not diplayed and I see the background from the JFrame where the WebView is placed. If I disable the JFXPanel I can see the whole Canvas with the video.
I also tried to add a JPanel as the lower Level. The result was like I want to be the Canvas. I can see the complete JPanel and on top of it, it displays the WebView.
So, what can I do to make the Canvas be strong enough to display all-over the Frame. I think canvas.setOpaque would fix the problem but this Method is not available.
UPDATE:
//BROWSER
this.jfxPanel = new JFXPanel();
this.jfxPanel.setOpaque(false);
this.jfxPanel.setBounds(0,0,MainFrame.VIDEO_SIZE_X,MainFrame.VIDEO_SIZE_Y);
PlatformImpl.startup(new Runnable() {
public void run() {
webView = new WebView();
webView.setPrefSize(MainFrame.VIDEO_SIZE_X-100,MainFrame.VIDEO_SIZE_Y-100);
webEngine = webView.getEngine();
webView.setStyle("-fx-background-color: rgba(0,0,0,0)");
Scene scene = new Scene(webView,MainFrame.VIDEO_SIZE_X-100,MainFrame.VIDEO_SIZE_Y-100);
scene.setFill(javafx.scene.paint.Color.TRANSPARENT);
webEngine.documentProperty().addListener(new DocListener());
webEngine.loadContent("<body style='background : rgba(0,0,0,0);font-size: 70px;text-align:center;'>Test Transparent</body>");
jfxPanel.setScene(scene);
}
});
//add browser in upper level to JLayeredPane
this.videoPanel.add(jfxPanel, new Integer(100));
//CANVAS
this.videoCanvas = new Canvas();
this.videoCanvas.setVisible(true);
this.videoCanvas.setBounds(0,0, MainFrame.VIDEO_SIZE_X,MainFrame.VIDEO_SIZE_Y);
//add canvas at lower level to JLayeredPane
this.videoPanel.add(this.videoCanvas, new Integer(0));
The videoPanel
is the JLayeredPane. It is setVisible(true) and has the same size like canvas and the browser.
Thanks in advance!