Problem

By calling setEnabled(false), you can disable a button and give it a muted appearance and...

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 16.12’s program so that the factorial button is initially disabled. Enable it only after the user enters a character in the xBox text box. To enable it, create a key listener for the xBox text box, and have the key listener’s keyTyped event handler call setEnabled(true). Use the following key listener code skeleton:

private class KeyListener extends KeyAdapter{public void keyTyped(KeyEvent e){...}} // end class KeyListener

Note extends KeyAdapter in 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 KeyAdapter API class implements the KeyListener API interface.

Figure 16.12 modified Listener class for the FactorialButton program

Step-by-Step Solution

Request Professional Solution

Request Solution!

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.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 16
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT