JavaFX disableProperty有两个条件不起作用

时间:2015-04-18 06:27:03

标签: binding javafx

我遇到了问题

public class LoginController implements Initializable {
    @FXML protected Button loginButton;
    @FXML protected TextField email;
    @FXML protected PasswordField password;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        loginButton.disableProperty().bind(Bindings.and(email.textProperty().isEmpty(), password.textProperty().isEmpty()));
    }
}

在字段,电子邮件和密码都不为空之前,应禁用LoginButton ...

目前,LoginButton已启用,当我在任一字段中输入一个字符时,只留下另一个字段...

任何想法,我弄错了?

此致

1 个答案:

答案 0 :(得分:1)

使用OR

loginButton.disableProperty().bind(Bindings.or(email.textProperty().isEmpty(), password.textProperty().isEmpty()));