By calling
setEnabled(false),you can disable a button and give it a muted appearance and make its listener unresponsive to clicks on it. Modify Figure’s program so that the factorial button is initially disabled. Enable it only after the user enters a character in the
xBoxtext box. To enable it, create a key listener for the
xBoxtext box, and have the key listener’s
keyTypedevent handler call
setEnabled(true).Use the following key listener code skeleton:
private class KeyListener extends KeyAdapter{ public void keyTyped(KeyEvent e) { … }} // end class KeyListeneNote
extends KeyAdapterin the above class heading. An adapter class implements an interface by providing an empty-bodied method for each method in the interface. In this case, the
KeyAdapterAPI class implements the
KeyListenerAPI interface.
Figure Modified Listener class for the FactorialButton program

We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.