1 of 8

Adanced Java Programming

Event Classes & Listener Interfaces in AWT

Smt.M.Jeevana Sujitha

Assistant Professor

Department of Computer Science and Engineering

SRKR Engineering College, Bhimavaram, A.P. - 534204

2 of 8

OBJECTIVES

The Objective of this lecture is

  • To learn about Event Classes & Listener Interfaces in AWT.

3 of 8

Event Classes

  • The following are the list of Event classes in AWT.
  • ActionEvent: It is generated when button is clicked or the item of a list is double clicked.
  • KeyEvent: It is generated when user entering the character through keyboard.
  • MouseEvent: It is generated when we change the state of a mouse.
  • WindowEvent: It is generated when we change the state of window.
  • ItemEvent: It is generated when we click on the checkbox, radio button and list.

4 of 8

Event Classes

  • AdjustmentEvent: It is generated
  • TextEvent: It is generated when we change the state of a text.

by

adjustable objects.

  • ComponentEvent: It is generated when we change the state of window.
  • ContainerEvent: It is generated when we change the state of window.
  • MouseMotionEvent: It is generated when we change the state of window.

5 of 8

Listener Interfaces

  • By default every component in a Frame is static. We can not

perform any action on that component.

  • So in order to make our components dynamic we use the listeners.
  • The following are the list of listener interfaces in AWT.
  • WindowListener: It is notified when we change the state of a

window.

Methods:

public abstract void windowOpened(WindowEvent e) public abstract void windowClosed(WindowEvent e) public abstract void windowClosing(WindowEvent e) public abstract void windowActivated(WindowEvent e) public abstract void windowDeactivated(WindowEvent e) public abstract void windowIconfied(WindowEvent e) public abstract void windowDeiconfied(WindowEvent e)

6 of 8

Listener Interfaces

  • ActionListener: It is notified whenever we click on the button, TextField, TextArea or menu item.
  • It is notified against ActionEvent. Methods:

public abstract void actionPerformed(ActionEvent e)

  • ItemListener: It is notified when we click on the checkbox, radio button and list.
  • It is notified against ItemEvent. Methods:

public abstract void itemStateChanged(ItemEvent e)

7 of 8

Listener Interfaces

  • KeyListener: It is notified whenever we change the state

of a key. It is notified against KeyEvent.

Methods:

public abstract void KeyPressed(KeyEvent e) public abstract void KeyReleased(KeyEvent e) public abstract void KeyTyped(KeyEvent e)

  • MouseListener: It is notified when we change the state of

a mouse and it is notified against MouseEvent.

Methods:

public abstract void mouseClicked(MouseEvent e) public abstract void mouseEntered(MouseEvent e) public abstract void mouseExited(MouseEvent e) public abstract void mousePressed(MouseEvent e) public abstract void mouseReleased(MouseEvent e)

8 of 8

THANK YOU