An event is defined as the act of changing the state of an item or behavior. A button click, cursor movement, key press via keyboard, or page scrolling are all examples of actions.
Various event classes can be found in the java.awt.event package.
There are three major components to event management.
A source generates an Event and sends it to one or more registered listeners. When the listener receives an event, it processes it and returns. Several Java packages, including java.util, java.awt, and java.awt.event, support events.
Event Class | Listener Interface | Description |
---|---|---|
ActionEvent | ActionListener | An event that signals the occurrence of a component-defined action, such as a button click or the selection of an item from the menu-item list. |
AdjustmentEvent | AdjustmentListener | An Adjustable object, such as a Scrollbar, emits the adjustment event. |
ComponentEvent | ComponentListener | An Adjustable object, such as a Scrollbar, emits the adjustment event. An event that indicates that a component has moved, its size has changed, or its visibility has changed. |
ContainerEvent | ContainerListener | When a component is added to (or withdrawn from) a container, a container object generates this event. |
FocusEvent | FocusListener | These are events connected to attention, such as focus, focusin, focusout, and blur. |
ItemEvent | ItemListener | An event that indicates whether or not an item was selected. |
KeyEvent | KeyListener | An event that occurs as a result of a series of keystrokes on the keyboard. |
MouseEvent | MouseListener & MouseMotionListener | The events that occur as a result of a user’s engagement with the mouse (Pointing Device). |
MouseWheelEvent | MouseWheelListener | An event that indicates that the mouse wheel in a component was rotated. |
TextEvent | TextListener | An event occurs when the text of an object changes. |
WindowEvent | WindowListener | An event that indicates whether a window’s status has changed. |
Listener Interface | Methods |
---|---|
ActionListener | actionPerformed() |
AdjustmentListener | adjustmentValueChanged() |
ComponentListener | componentResized() componentShown() componentMoved() componentHidden() |
ContainerListener | componentAdded() componentRemoved() |
FocusListener | focusGained() focusLost() |
ItemListener | itemStateChanged() |
KeyListener | keyTyped() keyPressed() keyReleased() |
MouseListener | mousePressed() mouseClicked() mouseEntered() mouseExited() mouseReleased() |
MouseMotionListener | mouseMoved() mouseDragged() |
MouseWheelListener | mouseWheelMoved() |
TextListener | textChanged() |
WindowListener | windowActivated() windowDeactivated() windowOpened() windowClosed() windowClosing() windowIconified() windowDeiconified() |
Note: Example of event handling already seen in the previous post.
Note: also read about the JApplet class in Applet
If you like my post, please follow me to read my latest post on programming and technology.
https://www.instagram.com/coderz.py/
https://www.facebook.com/coderz.py
Staying up to the mark is what defines me. Hi all! I’m Rabecca Fatima a keen learner, great enthusiast, ready to take new challenges as stepping stones towards flying colors.
Problem Statement: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example…
Given an integer A. Compute and return the square root of A. If A is…
Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…
A heap is a specialized tree-based data structure that satisfies the heap property. It is…
What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…