Event in java

Event

  • An event is an object that describes a state change in a source
  • Events can be generated as a result of user action or can be generated indirectly as a result of some other event
  • The activities that cause events are pressing a button, entering a character via keyboard, selecting an item in a list & clicking the mouse
  • Events may be generated when a timer expires, a counter exceeds a values, a s/w or h/w occurs or an operation is completed

Event Handling Mechanisms

  • Java uses the delegation event model which uses the following mechanisms
  • The delegation event model
    • Source generates an event & notifies 1 or more listeners
    • Implement the appropriate interface in the listener so that it will receive the type of event desired
    • Listener processes the event & then returns

Event classes

ActionEvent
It generated when a button is pressed, a list item is double clicked or menu item is selected

AdjustmentEvent
It generated when a scroll bar is manipulated.

ComponentEvent
It generated when a component is hidden, moved, resized, or becomes visible.

ContainerEvent
It generated when a component is added to or removed from a container.

FocusEvent
It generated when a component gains or loses keyboard focus.

InputEvent
It is abstract super class for all component input event classes.

ItemEvent
It generated when a check box or list item is clicked; also occurs when a choice selection is made or a checkable menu item is selected or deselected.

KeyEvent
It generated when input is received from the keyboard.

MouseEvent
It generated when the mouse is dragged, moved, clicked, pressed, or released; also generated when the mouse enters or exits a component.

TextEvent
It generated when the value of a text area or text field is changed.

WindowEvent
It generated when a window is activated, closed, deactivated, deiconified, iconified, opened, or quit.

Leave a Reply

Your email address will not be published. Required fields are marked *