I just started using JavaFX. In my little Project I got two views. The first is filled with a tabpane, while the second one contains a button to add new tabs to the tabpane. That means I need to switch between the first and the second view to add new Tabs. The tabpane has one standart-tab wich is unable to close.
My Problem: If I add more than one new tab to my tabpane all tabs are painted over each other.
I already triedto prevent it like this: Init everything:
private ArrayList<Tab> allTabs = new ArrayList<Tab>();
Tab tab = new Tab();
allTabs.add(tab);
TabPane tp = new TabPane();
tp.getTabs().add(tab);
To set the selection I tried a few things:
tp.getSelectionModel().clearSelection();
tp.getSelectionModel().select(allTabs.size());
_________________________________________________________________
tp.getSelectionModel().clearSelection();
tp.getSelectionModel().select(tp.getTabs().size);
_________________________________________________________________
tp.getSelectionModel().selectLast();
_________________________________________________________________
tp.getSelectionModel().selectNext();
_________________________________________________________________
tp.getSelectionModel().clearAndSelect(tp.getTabs().size());;
I want to select the newest tab. This is already working but the old ones aren't deselected. The Problem disappears if I select tabs with a mouseclick.
I'm thankfull for any idea.
Is it possible that your using different FXMLLoaders? I had an simular problem while i was using the normal FXMLLoader and a coustom FXMLLoader. Just try to use the same in both cases. This is the way how it works for me.
If it doesn't fix your problem some pictures and some more code-fragments would be helpful to solve your problem.
Greetings