This program uses an anonymous inner class
(Note however that the program could be written using a top-level class in place of the anonymous class.)
The anonymous class begins in Listing 4.
Listing 4. Beginning of the anonymous listener class. |
---|
button.addActionListener(new ActionListener() {//Begin the anonymous class definition public void actionPerformed(ActionEvent e){ picture = world.getPicture(); //Set picture background to green. picture.setAllPixelsToAColor(Color.GREEN); picture.setMessageColor(Color.RED); //Display the student's name on the picture. picture.addMessage("Dick Baldwin",10,20); |
File: ay.htm | [Next] | [Prev] |