Here, I want to disable and enable button according to the value of the boolean.
boolean result=(txtItem.getText().isEmpty() && txtQty.getText().isEmpty());
btnOrder.disableProperty().bind(xxxxx);
what should I enter there??
If I understand what you are asking (in particular, assuming txtItem
and txtQty
are some kind of TextInputControl
), you can do
btnOrder.disableProperty().bind(Bindings.createBooleanBinding(
() -> txtItem.getText().isEmpty() && txtQty.getText().isEmpty(),
txtItem.textProperty(), txtQty.textProperty()));
or
btnOrder.disableProperty().bind(
Bindings.length(txtItem.textProperty()).isEqualTo(0)
.and(Bindings.length(txtQty.textProperty()).isEqualTo(0)));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With