MRodriguez08
MRodriguez08

Reputation: 191

Java FX Multiple Windows App

How are big applications (with lots of windows, lets say users administration, roles, payments, etc) designed. I'm a web developer and I'm used to develop different screens in different html files. I wanna know how to split windows generations in different files instead of having only one huge Application class. Thanks in advance..

Upvotes: 1

Views: 1432

Answers (2)

jewelsea
jewelsea

Reputation: 159291

The question is a bit too broad to thoroughly answer, but I still think providing a partial answer here might be useful.

For an implementation of Banislav's strategy of hyperlinks controlling a swappable pane (which does not use FXML), see the related question: How to have menus in java desktop application.

For a small FXML based framework for switching panes see: Loading new fxml in the same scene with associated sample code. Note that sample is for small apps, for large apps a more rigorous framework would be preferred.

The next step up from the small framework listed above would be something like afterburner.fx, which is "a minimalistic (3 classes) JavaFX MVP framework". Even though small, afterburner.fx would probably suffice to be used as the core for a medium sized application. You can find a small sample application built using afterburner.fx named airhacks-control.

For something a bit more involved you can study the source of SceneBuilder and SceneBuilderKit. SceneBuilder is an open source design tool written in JavaFX. Understanding and adapting that code may be challenging for somebody coming from a web background as its implementation differs significantly from a traditional web application.

For very large applications, basing the application on a fully featured platform such as NetBeans RCP would probably be a preferred approach, though, as of this time, that is probably a large and difficult task to do well and likely requires mixing multiple frameworks rather than writing everything purely in JavaFX.

Upvotes: 3

Branislav Lazic
Branislav Lazic

Reputation: 14806

In JavaFX, you can use similar approach as in web development.

Use BorderPane as root pane.

Create main menu

You can use MenuBar with Menus and MenuItems. You can also use TreeView or ListView on like left side of screen. To position TreeView/ListView on left side you could use BorderPane and set it to left with setLeft.

Approach I prefer would be to use HyperLink control. Add multiple HyperLink's to VBox and again, set them on left side of BorderPane. Upon click, they will handle event which set's desired form on center of BorderPane.

I.e.

enter image description here

Upvotes: 2

Related Questions