Java

What are Event Listener Interfaces in Java2 min read

In this article we will learn about various event listener interfaces in Java along with the methods available in each of those listener interfaces.

The event delegation model contains two main components. First are the event sources and second are the listeners. Most of the listener interfaces are available in the java.awt.event package. In Java, there are several event listener interfaces which are listed below:




ActionListener 

This interface deals with the action events. Following is the event handling method available in the ActionListener interface:

void actionPerformed(ActionEvent ae)

AdjustmentListener

This interface deals with the adjustment event generated by the scroll bar. Following is the event handling method available in the AdjustmentListener interface:

void adjustmentValueChanged(AdjustmentEvent ae)

ComponentListener

This interface deals with the component events. Following are the event handling methods available in the ComponentListener interface:

void componentResized(ComponentEvent ce)

void componentMoved(ComponentEvent ce)

void componentShown(ComponentEvent ce)

void componentHidden(ComponentEvent ce)

ContainerListener

This interface deals with the events that can be generated on containers. Following are the event handling methods available in the ContainerListener interface:

void componentAdded(ContainerEvent ce)

void componentRemoved(ContainerEvent ce)

FocusListener

This interface deals with focus events that can be generated on different components or containers. Following are the event handling methods available in the FocusListener interface:

void focusGained(FocusEvent fe)

void focusLost(FocusEvent fe)

ItemListener

This interface deals with the item event. Following is the event handling method available in the ItemListener interface:

void itemStateChanged(ItemEvent ie)

KeyListener

This interface deals with the key events. Following are the event handling methods available in the KeyListener interface:

void keyPressed(KeyEvent ke)

void keyReleased(KeyEvent ke)

void keyTyped(KeyEvent ke)

MouseListener

This interface deals with five of the mouse events. Following are the event handling methods available in the MouseListener interface:

void mouseClicked(MouseEvent me)

void mousePressed(MouseEvent me)

void mouseReleased(MouseEvent me)

void mouseEntered(MouseEvent me)

void mouseExited(MouseEvent me)

MouseMotionListener

This interface deals with two of the mouse events. Following are the event handling methods available in the MouseMotionListener interface:

void mouseMoved(MouseEvent me)

void mouseDragged(MouseEvent me)

MouseWheelListener

This interface deals with the mouse wheel event. Following is the event handling method available in the MouseWheelListener interface:

void mouseWheelMoved(MouseWheelEvent mwe)

TextListener

This interface deals with the text events. Following is the event handling method available in the TextListener interface:

void textValueChanged(TextEvent te)

WindowFocusListener

This interface deals with the window focus events. Following are the event handling methods available in the WindowFocusListener interface:

void windowGainedFocus(WindowEvent we)

void windowLostFocus(WindowEvent we)

WindowListener

This interface deals with seven of the window events. Following are the event handling methods available in the WindowListener interface:

void windowActivated(WindowEvent we)

void windowDeactivated(WindowEvent we)

void windowIconified(WindowEvent we)

void windowDeiconified(WindowEvent we)

void windowOpened(WindowEvent we)

void windowClosed(WindowEvent we)

void windowClosing(WindowEvent we)

Take your time to comment on this article.

Leave a Comment