使用绑定.
特定
TextField textField1 ;
TextField textField2 ;
Run Code Online (Sandbox Code Playgroud)
你可以做
BooleanBinding textField1Valid = Bindings.createBooleanBinding(() -> {
// check textField1.getText() and return true/false as appropriate
}, textField1.textProperty());
BooleanBinding textField2Valid = Bindings.createBooleanBinding(() -> {
// check textField2.getText() and return true/false as appropriate
}, textField2.textProperty());
Run Code Online (Sandbox Code Playgroud)
然后
Button button = new Button("OK");
button.disableProperty().bind(textField1Valid.not().or(textField2Valid.not()));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3271 次 |
| 最近记录: |