1

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..

MRodriguez08
  • 189
  • 1
  • 7

2 Answers2

3

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.

Community
  • 1
  • 1
jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • Thanks for the answer, for now it seems to me that Branislav's approach is enough considering my knowledge level and the size of my application. On the other hand is nice to know that there are some JFX frameworks to develop these kinds of apps, so soon I will do some research to get in touch. Thanks @jewelsea – MRodriguez08 Feb 11 '15 at 15:58
2

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

Branislav Lazic
  • 14,388
  • 8
  • 60
  • 85
  • Thanks very much for the quick answer! that was exactly what I wanna know! So, I gess I should implement each Pane in separated files and add them programatically in (i.e.) onclick right? – MRodriguez08 Feb 10 '15 at 23:45
  • Thanks very much again @Branislav Lazic, I'll go on with this solved out. – MRodriguez08 Feb 10 '15 at 23:48
  • @MRodriguez08 Also, worth of mentioning. When you want to set pane on center of `BorderPane` don't forget to call `setCenter(null)` before of that. It's used to remove current pane and "clear terrain" for new one. – Branislav Lazic Feb 10 '15 at 23:50
  • Nice advice, I had a little bit of experience with swing and I used to do it that way :) – MRodriguez08 Feb 10 '15 at 23:52
  • There's no reason to call `setCenter(null)` before calling `setCenter(...)` with another pane. (All you're doing is setting a property, there is no need to set it to one thing just to set it to something else afterwards.) – James_D Feb 11 '15 at 02:42