A good answer might be:To a listener object. But our program does not have one, yet. | |
ActionListenerAn ActionListener is a listener for button clicks. ActionListener is an interface (not a class) that contains the single method: The ActionEvent parameter it expects is an object that represents an event (for us, a button click.) It contains information that can be used in responding to the event. Since ActionListener is an interface, you use it with a class that will implement the actionPerformed() method. It is common to implement the interface in the same class that contains the button(s):public void actionPerformed( ActionEvent evt) ;
This is a slightly different approach than was used with the WindowEvent of the previous chapter, where the WindowAdapter class was extended to define a spearate class for the listener. | |
QUESTION 5:Our class definition buttonDemo says that it implements the ActionListener interface. What does this mean? Click Here after you have answered the question |