Tobias
Tobias

Reputation: 45

JavaFX: use only one scene or multiple scenes to build UI with static and dynamic content?

cheers,

i am fairly new to JavaFX2. I already did some research about the basic principles: Stages that contain Scenes. Scenes in turn can be switched. But only switching parts of scene does not seem to be common usage.

My Problem: I am trying to create an application with a titlepane (containing a lable and some buttons) and a Pane containing further dynamic content. The titlepane will stay there throughout the whole lifecycle.

Now i am confused about what is the best way to achieve such a layout. I found some ideas like here to make my root layout a Borderpane and switch its center. In that case i would end up with only one scene. But i am not shure if that´s how it should be done.

Any help and ideas on this topic is very appreciated. cheers tobi

P.S.: i am using FXML files to create my layout and Controller to handle each view.

Upvotes: 3

Views: 2598

Answers (1)

jewelsea
jewelsea

Reputation: 159416

Well there is this question: Loading new fxml in the same scene, which is (perhaps) a duplicate of yours. I wouldn't call the solution there a "best practice", but it is likely decent enough for a smallish app. The answer provides a small framework for swapping fxml controlled content panes in and out of a portion of the main scene.

Similar is Angela's Managing Multiple Scenes.

More comprehensive solutions are things like Gluon Desktop (which I haven't used) or afterburner.fx.

For an actual non-trivial application, look at the SceneBuilder application, which is probably the best "best practice" reference you could find for a decent sized JavaFX application. But, as it is non-trivial, understanding its architecture is likely non-trivial too.

Upvotes: 2

Related Questions