0
votes

I've written some complex GUIs in Swing and I've never used a graphical tool. I've always just written the Java code. Now I'm writing my first JavaFX GUI, and it will be a large, complex GUI that gets all data values from the cloud. I've started doing the initial work with SceneBuilder, but I've run into a problem where SceneBuilder expects the .fxml and controller .java file to be in the same directory. It seems that the SceneBuilder developers think that JavaFX projects should have all of their files in one directory as if we are building toy demos instead of industrial strength GUIs.

I've also noticed that there are no architectural guidelines as to what should go into controller classes. If there are patterns and idioms that should guide the design and interaction between the .fxml file(s), the controller class(es), and the rest of the GUI classes I haven't been able to find them. Large, complex GUIs need to follow proven idioms or they'll become unmaintainable. A controller class could become several thousand lines long if all business logic and interaction with the cloud was in the controller class. Yet there seems to be no guidelines for what should be in the controller class and what should not be in the controller class.

I worry about large fxml structures becoming unmaintainable. If each .fxml file is one scene a GUI could be composed from multiple .fxml files, but I haven't found good guidance or examples of how to do this.

I'm tempted to drop SceneBuilder now before I invest much more time into .fxml. Have others been able to write large, complex GUIs that rely on all data coming from and being written to the cloud using SceneBuilder?

Thanks.

1
The FXML-controller idiom is basically an implementation of the Model-View-Presenter pattern. (FXML is the view, "controller" is the presenter. Model is application-specific.) SceneBuilder itself (which is a reasonably large application) is written with FXML and controllers. - James_D
You have a few misconceptions here: 1. "It seems that the SceneBuilder developers think that JavaFX projects should have all of their files in one directory." No, not at all: again see SceneBuilder as an example. It's better (imho) to have each FXML, controller, and CSS (if you need it) in a package together, but separate different parts of the UI into separate packages. But you would have arbitrarily many packages with arbitrary structure like this. - James_D
"A controller class could become several thousand lines long if all business logic and interaction with the cloud was in the controller class." just sounds like you don't have a model, with your services decomposed from the model. Maybe oracle.com/technetwork/articles/java/javafxinteg-2062777.html is helpful? And perhaps also see afterburner.adam-bien.com and links from there for some ideas on managing larger projects. - James_D
If you look closely at the videos in afterburner.adam-bien.com it looks like Adam Bien has .fxml and .css files in the same directory as his .java files. Are we supposed to break the maven standard directory layout in order to use SceneBuilder? - Dean Schulze
I cloned the SceneBuilder source code and it has the .fxml files under src/main/resources/ but using the same package structure as the corresponding Java classes do. I did this with my .fxml file (use the same package structure as my controller class uses) but SceneBuilder still can't find my controller. - Dean Schulze

1 Answers

1
votes

Absolutely.

I have designed a configuration driven UI with almost no coupling. Using FXML I can store the views in the DB and have actions that read those locations and load the UIs, which inject controllers, etc...

We will have hundreds of stages by time this app is done, and FXML and SceneBuilder cut design/development/maintenance time by MONTHS.

I think it's the strength of JavaFX.

Editing to show where you can add the controller...

enter image description here