简体   繁体   中英

Java and Scene Builder How to Disable and Enable Tab

I'm building an application using NetBeans and Scene Builder. I've got a TabPane, however, I wish to disable the 3rd tab in the pane when the btnAnonymousClientClick is clicked, how would I go about doing so?

My Code:

public class FXMLDocumentController implements Initializable {
    @FXML
    private Button btnCreateAnonymousClient;
    @FXML
    private Button btnCancel;
    @FXML
    private TextField txtAnonymousClientFirstName;
    @FXML
    private Label lblFirstName;
    @FXML
    private Label lbl;
    @FXML
    private TabPane tabControlPane;

    /**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    

    @FXML
    private void btnAnonymousClientClick(ActionEvent event) {

    }

    @FXML
    private void btnAnonymousClientCancel(ActionEvent event) {

    }

}

You can disable a Tab by adding a fx:id to it and adding it to your code.

@FXML
private Tab yourTabFXID


yourTabFXID.setDisable(true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM