Semantic events are defined at a higher-level to encapsulate the semantics of user interface components model. Now let us see what are the various semantic event classes and what they generate:
An ActionEvent object is generated when a component is activated
An AdjustmentEvent Object is generated when scrollbars and other adjustment elements are used.
A TextEvent object is generated when text of a component is modified.
An ItemEvent is generated when an item from a list, a choice or checkbox is selected.
Low-Level Events is one that represents a low-level input or windows-system occurrence on a visual component on the screen. The various low-level event classes and what they generate are as follows:
A ContainerEvent Object is generated when component are added or removed from container.
A ComponentEvent object is generated when a component is resized, moved etc.
A FocusEvent object is generated when component receives focus for input.
A KeyEvent object is generated when key on keyboard is pressed, released etc.
A WindowEvent object is generated when a window activity, like maximizing or close occurs.
A MouseEvent object is generated when a mouse is used.
A PaintEvent object is generated when component is painted.
Event Listeners: An object delegates the task of handling an event to an event listener. When an event occurs, an event object of the appropriate type (as illustrated below) is created. This object is passed to a Listener. A listener must implement the interface that has the method for event handling. A component can have multiple listeners, and a listener can be removed using removeActionListener () method. Next question in your mind must be what is an interface?. An Interface contains constant values and method declaration. The difference between classes and interface is that the methods in an interface are only declared and not implemented, that is, the methods do not have a body. What is the Need for interface? Are interfaces are used to define behavior protocols (standard behavior) that can be implemented by any class anywhere in the class hierarchy. The java.awt.event package contains definitions of all event classes and listener interface. The semantic listener interfaces define by AWT for the above mentioned semantic events are:
The low-level event listeners are as follows:
blog comments powered by Disqus