Java和Scene Builder如何禁用和启用选项卡

时间:2015-07-08 19:23:48

标签: java scenebuilder

我正在使用NetBeans和Scene Builder构建应用程序。我有一个TabPane,但是,我希望在点击btnAnonymousClientClick时禁用窗格中的第三个标签,我该怎么做呢?

我的代码:

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) {

    }

}

1 个答案:

答案 0 :(得分:1)

您可以通过向其添加fx:id并将其添加到代码来禁用Tab。

@FXML
private Tab yourTabFXID


yourTabFXID.setDisable(true);