The nextToken method is used to extract the next set of characters. We then create a Rectangle object based on the tokens that we extract. If we fail to extract four numbers, execution proceeds to the catch statement, which prints a usage error. We again call the prepareImage method on each Image to begin its download. The Rectangle, Image, and URL are then added to their respective Vectors, and setup is complete.
Event handling All of the event handling is taken care of in the handleEvent method.
We need to check for mouse activity, and there are several events that can occur. If all of the possible mouse events are listed as cases in the switch without break statements between them, then the code found under the last case will be executed if any of these event types happen. We first create a temporary integer variable, next , that will be the index of the region with the most recent activity. If the mouse has not exited the applet, then we run through the defined regions to find out where the event occurred. The Event object is instantiated automatically when something happens, and has variables that hold the mouse coordinates at the time of the event.