By calling setDisable(true), you can disable a button and give it a muted (grayed out) appearance and
Question:
By calling setDisable(true), you can disable a button and give it a muted (grayed out) appearance and make its handler unresponsive to clicks on it. Modify the FactorialButton program so that the button is initially disabled. Enable it only after the user types a key when the xBox text box has focus. When the user clicks the Factorial button, calculate and display the factorial and disable the button.
(1) Declare btn to be an instance variable.
(2) Instead of calling setOnAction, have your xBox control call setOnKeyTyped, like this: xBox.setOnKeyTyped(e -> btn.setDisable(false));
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Introduction To Programming With Java A Problem Solving Approach
ISBN: 9781260575248
3rd International Edition
Authors: John Dean
Question Posted: