Event handling |
So far we have seen that we can create and install a GUI component as follows:
We can also set the program up so that the WindowController object is notified whenever the user interacts with a GUI item: DoubleComboBoxDrawing.
In order to get the program to respond to events associated with the object, we must also:
colorMenu.addActionListener(this);
public class DrawingProgram extends WindowController implements ActionListener { ... }
public void actionPerformed(ActionEvent event) { ... }
Check out the "GUI cheat sheet" in the documentation section of the course web page for a good summary of how to use GUI components in your program!
Event handling |