Swing has the following types of events:

Action events:

Action events occur when a user completes an action using one of the following components: JButton, JCheckBox, JComboBox, JTextField, or JRadioButton.

A class must implement ActionListener interface in order to handle those events. The actionPerformed(ActionEvent) method is the only method of the ActionListener interface.

Adjustment Events:

Adjustment Events occur when a JScrollBar component is moved. To handle these events, a class must implement the AdjustmentListener interface. The adjustmentValueChanged(AdjustmentEvent) method is the only method in the AdjustmentListener interface.

Focus Events

Focus events occur when any component gains or loses input focus on a graphical user interface. Focus applies to all components that can recieve input.

To handle a focus event, a class must implement the FocusListener interface.

Item Events:

Item events occur when an item is selected or deselected on any of the following components: JButton, JCheckBox, JComboBox, or JRadioButton. A class must implement the ItemListener interface in order to handle these events.

Key Events:

Key events occur when a key is pressed on the keyboard. Any component can generate these events, and a class must implement KeyListener interface to support them.

Mouse Events:

Mouse events are generated by the following types of user interaction:

  • A mouse click
  • A mouse entering a component's area
  • A mouse leaving a component's area

Any component can generate these events, and a class must implement MouseListener interface to support them.

Mouse Motion Events:

Mouse motion events occur when a mouse is moved over a component. Any component can generate these events, and a class must implement MouseMotionListener interface to support them.

Window Events:

Window events occur when a user opens or closes a window object, such as a JFrame or a JWindow. Any component can generate these events and a class must implement WindowListener interface to support them.