Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
Notice that in this little program I did something kind of cool: I made the CBn class a button that is its own action listener. Nice, right? So the line
this.addActionListener(this);is basically saying "I am my own ActionListener".
HW1Frame F = new HW1Frame();for the first line of main, suppose I had written:
JFrame F = new HW1Frame();Would the result be: compile-time error, run-time error, or OK? Explain your answer thoroughly?
Button clicked 3 times.The nicest way to do this is to make the CBn class listen not only for button clicks, but also for window closing events!
When we define a class that listens for window events, we must either implement the WindowListener interface or extend the WindowAdapter class. (see the previous lesson's notes) Extending the class is certainly easier. Explain why, however, if we want to modify our CBn class so that it not only serves as a button and listens for button clicks, but also listens for window events, we cannot extend WindowAdapter. Instead, wee must implement WindowListener.
____ My program works completely and correctly ____ My program does not work completely and correctly