i am working on a project for getting an overview about bank accounts and their transfers (of my own).
Therefore I create a BorderPane, on top there is a menu bar, on the left there is a nagivation (treeView).
The idea is now, when selecting on a treeItem, the content of the middle part of my BorderPane should change.
So when I click on my first CreditCard which is listed in the Navigation Tree, an overview should appear in the middle of the BorderPane. Therefore I have created a FXML-Document.
When I click on 'Overview', all my CreditCards should appear with an overview like 'amount at beginning of the month' and 'amount now'.
I got a FXML for this look, too.
The problem is: I'm not pretty sure how to handle the controls of each different FXML-File. Should each FXML-File has its own controller?
Or should I just use one controller to handle each interacted control and just call another class to process the information that need to be done?
How would you do it?
Asked
Active
Viewed 131 times
-1

BlackACE
- 21
- 5
1 Answers
0
Each FXML file should have its own controller.
Do not try to share a controller between different FXML files, therein lies disaster and pain. Explanation of pain:
- JavaFX multiple FXML and 1 shared controller
- Have multiple FXML files (created in SceneBuilder), but only one controller. Does each scene load it's own copy of the controller?
The idea is that you don't share a controller, instead you share model or objects or an abstracted persistence layer between different controller instances: