Ok, this is an interesting question! You are right, you cannot set the mnemonics directly on the tab. But you can add a component as a tab graph that supports mnemonics:
private class MTab extends Tab
{
public MTab(String pText)
{
super();
Button fakeLabel = new Button(pText);
fakeLabel.setMnemonicParsing(true);
fakeLabel.getStyleClass().clear();
setGraphic(fakeLabel);
fakeLabel.setOnAction(ev -> {
if (getTabPane() != null) {
getTabPane().getSelectionModel().select(this);
}
});
}
}
Using this tab:
TabPane tabs = new TabPane();
tabs.getTabs().add(new MTab("_this is a test"));
tabs.getTabs().add(new MTab("t_his is a test"));
tabs.getTabs().add(new MTab("th_is is a test"));
Allows you to switch using shortcuts.
eckig source
share