go to previous page   go to home page   go to next page


Visually nothing happens. The actionPerformed() method is called with a new Event object, but it changes nothing. If you feel like some fun, modify the code so that each click changes the background color.

Program's Output

The Java system automatically paints the frame when any of several things has happened:

However, a mere button click does not necessarily mean that a frame should be repainted. If it does, as it does in this program, call repaint() in the actionPerformed() method.

clicking a button

The pictures show the output of the program. The original frame is on the left. On the right is the frame after a button click.


(Memory Test: ) What is the name of the method that receives ActionEvents when a button is clicked?