Michael
Michael

Reputation: 71

how to enable/disable tab in Javafx?

How to enable tab when default is disabled in fxml?

... some code ...
 <TabPane fx:id="tabpan"  prefHeight="256.0" prefWidth="497.0" tabClosingPolicy="UNAVAILABLE">
 <Tab id="shoppingltab" disable="true" text="Lists">
...

in controller I did make

@FXML private TabPane tabpan;

but i've got no idea how to enable this tab...

thx for help in advance

Upvotes: 1

Views: 5101

Answers (2)

Rahul Singh
Rahul Singh

Reputation: 19622

You can just use the setDisable method on any tab that is bind to the controller

Upvotes: 0

James_D
James_D

Reputation: 209225

Inject the tab into the controller (as you do with the tab pane):

<Tab fx:id = "shoppingltab" ... >

and in the controller

@FXML private Tab shoppingltab;

Then you can enable the tab in the controller with

shoppingltab.setDisable(false);

Upvotes: 5

Related Questions