Event handling |
So far we have seen that we can create and install a GUI component as follows:
We can set the program up so that whenever the user interacts with a GUI item, specific code should be executed. The program FallingBallSize illustrates that with the speed buttons.
In order to get the program to respond to events associated with the GUI item, we must also associate code with an action on the GUI item by invoking (not writing!) methods like onMousePress, onChangeDo. etc. As we saw last time with DoubleDrawing, we can put multiple items in different parts of the window by inserting them into containers and then inserting the containers into the window.
Event handling |