I have a GUI created using JavaFX with FXML.
There are many components in this GUI, and not all of them are needed at one time.
For example, imagine a graphical interface that receives a list of cities from its server side. Each city is described on its own tab (and is described by many nodes). A set of cities contains 30 elements.
When the GUI starts up, it asks the server for a list of cities. The server returns a random "subset" of cities (thus, it can be Moscow + Riga + New York or St. Petersburg + Tokyo, or only Amsterdam, or all 30 cities in one set).
So. I donโt need to have all 30 tabs in my node tree (I suppose they just โeat upโ the memory and nothing else).
I want to control the number of tabs that I have at every moment of my GUI.
The first simple solution I have is the following:
- Create an FXML file that contains components for all cities.
- During initialization in the controller class, delete the tabs that are not needed.
I have problems with this solution. First, I donโt know if tabPane.getTabs().remove(index) really removes the tab and all its content from the tree of nodes. Secondly, all unnecessary tabs will be initialized before they are deleted, so in any case they will use memory and resources, and my graphical interface may be slower than it should be.
My second solution:
- Make a lot of FXML. One for all cities, one for each city and one for each city combination.
But many FXML will have many ways, so this solution is also not useful.
The solution I dream of:
- Create an FXML file for each city and one for the main tabbed application.
- Load the contents of an FXML city file into a dynamic table if necessary.
So, if someone has ideas for this task or they know the solution, please help me with this ...
source share