How to open a new tab first when open new tab

2019-09-08 15:05发布

问题:

I have a JavaFX TabPane in which I add new tabs dynamically when I click on a tree node.

tabPane.getTabs().add(tab);
tabPane.getSelectionModel().select(tab);

Can you tell me how I can open a new tab and place it always first before the other tabs.

回答1:

Try:

tabPane.getTabs().add(0, tab);

http://docs.oracle.com/javase/7/docs/api/java/util/List.html#add%28int,%20E%29