JavaFX TabPane has a very strange behavior if you try to sort the tabs when there is not enough space to show all the tabs.
More precisely, the tab selection button (round button with a down facing arrow on the right of the tab pane header) that should show a drop-down list with all the tabs, doesn't show anything.
I've created a small test to reproduce the problem. Just click several times (till there is not enough space for all the tabs) on "Add new tab & sort" (or several times on "Add new tab" and then "Sort tabs"), and then click on the tab selection button in the top right corner... Just to see that it shows nothing at all!
Note that resizing the window to make all tabs fit, and then resizing it back so the tab selection button appears again, solves the issue.
Here is the code to reproduce. I'm using jdk1.8.0_92. Looks like a JDK bug?
public class TabPaneTest extends Application {
public static void main(String[] args) {
TabPaneTest.launch();
}
int i = 1;
@Override
public void start(Stage primaryStage) throws Exception {
TabPane tabPane = new TabPane();
tabPane.getTabs().add(new Tab("My beautiful tab " + i, new TextArea("pane " + (i++))));
Button add = new Button("Add new tab");
add.setOnAction(event -> {
tabPane.getTabs().add(new Tab("My beautiful tab " + i, new TextArea("pane " + (i++))));
});
Button addSort = new Button("Add new tab & sort");
addSort.setOnAction(event -> {
tabPane.getTabs().add(new Tab("My beautiful tab " + i, new TextArea("pane " + (i++))));
tabPane.getTabs().sort((o1, o2) -> o2.getText().compareTo(o1.getText()));
});
Button sort = new Button("Sort tabs");
sort.setOnAction(event -> {
tabPane.getTabs().sort((o1, o2) -> o2.getText().compareTo(o1.getText()));
});
VBox vbox = new VBox(tabPane, new HBox(add, addSort, sort));
primaryStage.setScene(new Scene(vbox));
primaryStage.setWidth(400);
primaryStage.setHeight(300);
primaryStage.show();
}
}

TabPaneSkin'sremoveTabs(see my answer below) is still present as of today on the Java 9 branch, so probably the bug is still there. I did not check the previous versions, but apparently till recently the sorting of tabs didn't work at all because of this bug (fixed in 2015): bugs.java.com/bugdatabase/view_bug.do?bug_id=8118423 - Denis