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.
You are given a stream of elements that is too large to fit into memory.…
The formula for the area of a circle is given by πr². Use the Monte…
Given an integer k and a string s, write a function to determine the length…
There is a staircase with N steps, and you can ascend either 1 step or…
Build an autocomplete system that, given a query string s and a set of possible…
Design a job scheduler that accepts a function f and an integer n. The scheduler…