JavaFX bind to multiple properties

前端 未结 3 559
忘了有多久
忘了有多久 2020-12-15 06:26

I have a simple fxml with a textfield and a button. I\'d like to have the button disabled if the textfield is empty. So I insert something like the following in my controlle

3条回答
  •  天命终不由人
    2020-12-15 07:30

    In addition to Andreys approach, I found that you can also do it like this:

        BooleanBinding booleanBinding = 
          textField.textProperty().isEqualTo("").or(
            textField2.textProperty().isEqualTo(""));
    
        button.disableProperty().bind(booleanBinding);
    

提交回复
热议问题