How to programmatically switch using tabs in JavaFX

Only one tab is displayed at a time. The user selects one using the mouse / keyboard. Suppose TabPane has three tabs, and the first has a button. When the user clicks the button, I want to open the second tab. Then there should be some code to switch to the second tab associated with the button.

Is this possible programmatically? If so, how?

+7
java javafx
source share
1 answer

Try

tabPane.getSelectionModel().select(index); 

or

 tabPane.getSelectionModel().select(someTab); 

or

 tabPane.getSelectionModel().selectNext(); 

Or...

+24
source share

All Articles