Prior to this discussion, we looked at Java classes and objects and at methods to manipulate an object's variables. We have also looked briefly at several interface components, such as buttons and panels. However, we have not considered how to make anything happen. That is, how to make a button do something or how to start the flow of messages among objects. The key to making a Java program do something lies in events.Many programs< after they are started and initialized, go into a wait state waiting for something to happen. One important set of somethings is user interface actions: the user selects a menu option, clicks on a window with the mouse, types something on the keyboard, etc. At a very deep level of the system, these actions are observed and paramaterized, and their symbolic representations are passed up through several layers until they arrive at the application program. In java, these actions emerge as
Events
.The Java AWT provides an
Event
class, and the "events" that are generated by users' actions are conventional Java objects, realized by instantiating theEvent
class.