Question: 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

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 17.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 Key Listener extends KeyAdapter ( public void key Typed (Key Event e) ( } } // end class

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 17.12:

private class Listener implements ActionListener ( public void action Performed (ActionEvent e) { int x; //

private class Key Listener extends KeyAdapter ( public void key Typed (Key Event e) ( } } // end class KeyListener

Step by Step Solution

3.44 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Based on the instructions provided and the code from Figure 1712 we need to modify the program to disable the factorial button initially and enable it ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction To Programming With Java A Problem Solving Approach Questions!