Search code examples
javafxwebviewoverlayjxbrowser

JXBrowser overlay does not appear with BrowserType.HEAVYWEIGHT mode


I'm trying to integrate Cesium (a HTML5 WebGL 3D map tool) into a JavaFX application using JXBrowser. I need JavaFX overlay panel in front of the map but it doesn't work.

When I instantiate a new (JX)Browser in LIGHTWEIGHT mode, it works, I can see my overlay, but the rendering is very slow because it's done by the CPU. I really need the HEAVYWEIGHT mode for my needs but I don't understand why I can't put a Node (StackPane or any other) in front of the HEAVYWEIGHT Browser.

I tried to put my overlay to the own BrowserView Stackpane children, tried to add both one after one in a container... Also tried toBack(), toFront() without success. Everything that works with standard containers and in the LIGHTWEIGHT mode don't works in HEAVYWEIGHT.

Any idea or code sample ?

Help will be very appreciated because I have to do a proof of concept.

Thanks a lot.


Solution

  • In HEAVYWEIGHT rendering mode a native Chromium window that renders HTML content is embedded into JavaFX container. Most of JavaFX controls are lightweight, so they cannot be displayed on top of heavyweight controls. This is a well known limitation of JavaFX/Swing GUI toolkits. In your case you need to use LIGHTWEIGHT rendering mode only, or, to use HEAVYWEIGHT, you need to get rid of the case when you display something on top of HEAVYWEIGHT control.