Question

I have an application that uses a javafx Scene to render something, and I want to put that rendering into some GUI that I made, also in javafx. How would I do that?

Basically is there some container I can put a scene into and then put that container into the GUI.

Sorry if it's a newbie question, I am new to JavaFX

Was it helpful?

Solution

Java 8 has a SubScene, for which some possible uses (from the javadoc) are:

The SubScene class is the container for content in a scene graph. SubScene provides separation of different parts of a scene, each of which can be rendered with a different camera, depth buffer, or scene anti-aliasing. A SubScene is embedded into the main scene or another sub-scene. Possible use cases are:

  • Mixing 2D and 3D content
  • Overlay for UI controls
  • Underlay for background
  • Heads-up display

A SubScene is just a Node, so you can place it in the scene graph of an existing scene wherever you want. An example of SubScene usage is in the answer to: How to create custom 3d model in JavaFX 8?

Generally SubScenes are for mixing 2D and 3D content. If you are not doing that, then SubScenes probably don't apply to your situation and Uluk's answer will better serve your needs.

OTHER TIPS

The scene has only a top parent node as a root. You can get it and to put into another scene.

((Pane) scene2.getRoot()).getChildren().add(scene1.getRoot());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top