JavaFX Media, WebView, and 3D
Use this skill for the core setup of JavaFX media playback, WebView / WebEngine, and 3D scene
graph primitives. Use javafx-web-maps-embedded-integration when the requirement is specifically
about JavaScript bridges, maps, or browser-delivered JavaFX.
Example
import javafx.scene.Group;
import javafx.scene.SceneAntialiasing;
import javafx.scene.SubScene;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Box;
import javafx.scene.web.WebView;
public class MediaWeb3DView extends BorderPane {
public MediaWeb3DView() {
var webView = new WebView();
webView.getEngine().load("https://openjfx.io");
var cube = new Box(120, 120, 120);
cube.setTranslateX(180);
cube.setTranslateY(160);
var subScene = new SubScene(new Group(cube), 360, 320, true, SceneAntialiasing.BALANCED);
subScene.setFill(Color.web("#202020"));
setLeft(webView);
setCenter(subScene);
}
}
Setup notes
- Add JavaFX modules deliberately:
javafx.media,javafx.web, andjavafx.graphics3D support only when the feature set needs them. - Keep core
WebViewusage simple here: loading content, sizing it correctly, and managing lifecycle. - Treat 3D as scene-graph work with its own camera, lighting, and picking decisions.
Gotchas
- Media codecs and native platform packaging requirements vary by target environment.
WebViewloading is asynchronous; do not assume content is immediately ready.- 3D scene graph usage has different performance and input constraints than standard 2D controls.