-1

I just simply want to change my tabs I created with TabPane from JavaFx with code. I want a Button who switch the Tab when I press. I search for a Function like:tabpane.selectTab(index) Have anyone a solution?

Majotube
  • 3
  • 1

1 Answers1

0

You need to get the selection model first

https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/TabPane.html#getSelectionModel--

And then you can select a tab.

https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/SingleSelectionModel.html#select-int-

There are other ways to select than by index, read the docs in 2nd link.

tabPane.getSelectionModel().select(index);

note, most or all selections in javaFX seem to use a selectionModel.

brian
  • 10,619
  • 4
  • 21
  • 79