If you want the Button
to be active if and only if all fields are filled (i.e. not empty), then you are using the wrong operator. Use ||
instead of &&
to make it work.
You can easyly see what's wrong, if you reformulate the formula from computeValue
using DeMorgan's laws; I write
a1, a2, ..., a6
instead of
`addnum.getText().isEmpty()`, `addt1.getText().isEmpty()`, ..., `addatt.getText().isEmpty()`:
the following statements are equivalent:
- the button is active
!(a1 && a2 && ... && a6)
(!a1 || !a2 ||...|| !a6)
- at least one field is filled
In contrast to that with ||
instead of &&
:
the following statements are equivalent:
- the button is active
!(a1 || a2 || ... || a6)
(!a1 && !a2 &&...&& !a6)
- all fields are filled