Introduction to OOP | Chapter 22: The AWT and Swing : | next | previous | audio | real | text |
class ColorButton extends Button implements ActionListener { private Color ourColor; public ColorButton (Color c, String name) { super (name); // create the button ourColor = c; // save the color value addActionListener (this); // add ourselves as listener } public void actionPerformed (ActionEvent e) { // set color for middle panel setFromColor (ourColor); } }