在JavaFX中清除验证标签的最佳方法是什么

在JavaFX中清除验证标签的最佳方法是什么,javafx,scenebuilder,Javafx,Scenebuilder,我正在为用户输入表单做一个基本的验证,我在每个输入下附加了验证标签的名称。但是在用户通过添加所需的文本来纠正问题后,这些标签将无法清除,因此我在脚本的开头为每个标签添加了nameOfLable.setText(null)。好的,这就成功了,但是如果我有20个或更多的验证标签,会发生什么呢。。。。这样做对吗?还有,关于如何验证单选按钮部分的任何线索 @FXML private void handleButtonAction(ActionEvent event) throws IOExcep

我正在为用户输入表单做一个基本的验证,我在每个输入下附加了验证标签的名称。但是在用户通过添加所需的文本来纠正问题后,这些标签将无法清除,因此我在脚本的开头为每个标签添加了nameOfLable.setText(null)。好的,这就成功了,但是如果我有20个或更多的验证标签,会发生什么呢。。。。这样做对吗?还有,关于如何验证单选按钮部分的任何线索

@FXML
    private void handleButtonAction(ActionEvent event) throws IOException {

    userIdLabel.setText(null);
    passwordLabel.setText(null);
    ipValueLabel.setText(null);


    Stage stage;
    Parent root;
    if(event.getSource()==btn1){

        if ((ipValue.getText().isEmpty() || ipValue.getText() == null)) {
         ipValueLabel.setText("*IP address is required");
        }
        else if ((userId.getText().isEmpty() || userId.getText() == null)) {
         userIdLabel.setText("*Enter Your UserID");
        }

        else if ((password.getText().isEmpty() || password.getText() == null)) {
         passwordLabel.setText("*Enter Your Password");
        }

        else {
       stage=new Stage();
       root = FXMLLoader.load(getClass().getResource("Myfile.fxml"));
       stage.setScene(new Scene(root));
       stage.setTitle("Status Page");
       stage.initModality(Modality.APPLICATION_MODAL);
       stage.initOwner(btn1.getScene().getWindow());
       stage.showAndWait();}

    }
    else {
        stage=(Stage) btn2.getScene().getWindow();
        stage.close();

    }


}

@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO
}    

}

您是否已经查看了本教程?是的,我相信clear按钮将清除整个表单,但我只想清除标签有许多框架可以使用:用于表单生成,或用于其他商品,最后但并非最不重要