SlideShare a Scribd company logo
By
Shraddha Sheth
Neel Shah
o The Event Handling Process
o Event Classes
o Semantic Event Handling in Applets
o Semantic Event Handling in an Application

Java Event Handling
Java Event Handling
Java Event Handling
Java Event Handling
Java Event Handling
enableEvents(WINDOW_EVENT_MASK | MOUSE_EVENT_MASK);
Go
WINDOW_OPENED
 The event that occurs the first time a window is made
visible.
WINDOW_CLOSING
 The event that occurs as a result of the close icon being
selected or Close being selected from the window’s system
menu.
WINDOW_CLOSED
 The event that occurs when the window has been closed.
WINDOW_ACTIVATED
 The event that occurs when the window is activated—
obtains the focus, in other words. When another GUI
component has the focus,you could make the window obtain
the focus by clicking on it, for
WINDOW_DEACTIVATED
 The event that occurs when the window is deactivated—loses the
focus, in other words. Clicking on another window would cause this
event.
WINDOW_GAINED_FOCUS
 The event that occurs when the window gains the focus. This implies
that the window or one of its components will receive keyboard
events.
WINDOW_LOST_FOCUS
 The event that occurs when the window loses the focus. This implies
that keyboard events will not be delivered to the window or any of
its components.
WINDOW_ICONIFIED
 The event that occurs when the window is minimized and reduced
to an icon.
WINDOW_DEICONIFIED
 The event that occurs when the window is restored from an icon.
WINDOW_STATE_CHANGED
 The event that occurs when the window state changes—when it
ismaximized or minimized, for instance.
processWindowFocusEvent(WindowEvent e)
This method is called for any window focus
events that arise as long as such events are
enabled for the window.
processWindowStateEvent(WindowEvent e)
This method is called for events arising as a
result of the window changing state.
processEvent(AWTEvent e)
This method is called first for any events that are enabled
for the component. If you implement this method and
fail to call the base class method, none of the methods
for specific groups of events will be called.
processFocusEvent(FocusEvent e)
 This method will be called for focus events, if they are
enabled for the component.
processKeyEvent(KeyEvent e)
This method will be called for key events, if they are
enabled for the component.
processMouseEvent(MouseEvent e)
This method will be called for mouse button events, if
they are enabled for the component.
processMouseMotionEvent(MouseEvent e)
This method will be called for mouse move and drag
events, if they are enabled for the component.
processMouseWheelEvent(MouseWheelEvent e)
This method will be called for mouse wheel rotation
events, if they are enabled for the component
The WindowListener Interface
The WindowFocusListener Interface
The WindowStateListener Interface
The MouseListener Interface
The MouseMotionListener Interface
The MouseWheelListener Interface
The KeyListener Interface
The FocusListener Interface
Java Event Handling
windowGainedFocus(WindowEvent e)
 Called when the window gains the focus such that the
window or one of its components will receive keyboard
events.
windowLostFocus(WindowEvent e)
Called when the window loses the focus. After this
event, neither the window nor any of its components
will receive keyboard events.
The WindowStateListener Interface
windowStateChanged(WindowEvent e)
Called when the window state changes—when it is
maximized or iconified.
Java Event Handling
The MouseMotionListener Interface
mouseMoved(MouseEvent e)
 Called when the mouse is moved within a component
mouseDragged(MouseEvent e)
 Called when the mouse is moved within a component
while a mouse button is held down
The MouseWheelListener Interface
mouseWheelMoved(MouseWheelEvent e)
Called when the mouse wheel is rotated
Go
The KeyListener Interface
This interface defines methods to respond to events
arising when a key on the keyboard is pressed or released.
keyTyped(KeyEvent e)
 Called when a key on the keyboard is pressed and then
released
keyPressed(KeyEvent e)
 Called when a key on the keyboard is pressed
keyReleased(KeyEvent e)
 Called when a key on the keyboard is released
The FocusListener Interface
This interface defines methods to respond to a component
gaining or losing the focus.
focusGained(FocusEvent e)
 Called when a component gains the keyboard focus
focusLost(FocusEvent e)
 Called when a component loses the keyboard focus Go
FocusAdapter
WindowAdapter
KeyAdapter
MouseAdapter
MouseMotionAdapter
MouseInputAdapter
Go
Java Event Handling
Semantic Event Listeners
ActionListener
void actionPerformed(ActionEvent e)
ItemListener
void itemStateChanged(ItemEvent e)
AdjustmentListener
void adjustmentValueChanged(AdjustmentEvent e)
Go
Example

More Related Content

PPTX
tL20 event handling
PPTX
Event handling in Java(part 1)
PPT
Java eventhandling
PPTX
Event Handling in Java
PPTX
Event Handling in JAVA
PPTX
Event Handling in java
PPTX
Event handling in Java(part 2)
tL20 event handling
Event handling in Java(part 1)
Java eventhandling
Event Handling in Java
Event Handling in JAVA
Event Handling in java
Event handling in Java(part 2)

What's hot (20)

PDF
Unit-3 event handling
PPTX
Event handling
PPTX
Advance Java Programming(CM5I) Event handling
PPT
Event handling63
PPTX
Event handling
PPTX
What is Event
PDF
JAVA GUI PART III
PDF
Ajp notes-chapter-03
PDF
Swing
DOCX
Lecture8 oopj
PDF
12 High Level UI Event Handling
PPTX
Chapter 11.5
PPT
Java gui event
DOCX
Dr Jammi Ashok - Introduction to Java Material (OOPs)
PPTX
Lesson 07 Actions and Commands in WPF
PPT
Graphical User Interface (GUI) - 2
PPT
Java: GUI
PPT
09events
PPT
25 awt
PPT
Advance Java Programming (CM5I) 2.Swing
Unit-3 event handling
Event handling
Advance Java Programming(CM5I) Event handling
Event handling63
Event handling
What is Event
JAVA GUI PART III
Ajp notes-chapter-03
Swing
Lecture8 oopj
12 High Level UI Event Handling
Chapter 11.5
Java gui event
Dr Jammi Ashok - Introduction to Java Material (OOPs)
Lesson 07 Actions and Commands in WPF
Graphical User Interface (GUI) - 2
Java: GUI
09events
25 awt
Advance Java Programming (CM5I) 2.Swing
Ad

Viewers also liked (7)

PPTX
Java programming-Event Handling
PPTX
PPT
Java awt
PDF
00 swing
PPS
Java session11
PDF
Java AWT
PPT
Applet life cycle
Java programming-Event Handling
Java awt
00 swing
Java session11
Java AWT
Applet life cycle
Ad

Similar to Java Event Handling (20)

PPT
engineeringdsgtnotesofunitfivesnists.ppt
PPT
Unit 5.133333333333333333333333333333333.ppt
PPTX
EventHandling in object oriented programming
PPTX
JAVA AWT
PDF
Event Handling in Java as per university
PPTX
event-handling.pptx
PDF
Mobile Application Development
PPT
PPT
PPTX
JAVA UNIT 5.pptx jejsjdkkdkdkjjndjfjfkfjfnfn
PPTX
Event Handling PRESENTATION AND PROGRAMMING
PDF
Yahoo presentation: JavaScript Events
PPT
event handling new.ppt
PDF
java-programming GUI- Event Handling.pdf
PPT
JAVA (CHAPTER 1 EXCEPTION HANDLING) NOTES -PPT
PPT
java - topic (event handling notes )1.ppt
PDF
Lecture 18
PPTX
Androd Listeners
PPTX
Java Abstract Window Toolkit (AWT) Presentation. 2024
PPTX
Java Abstract Window Toolkit (AWT) Presentation. 2024
engineeringdsgtnotesofunitfivesnists.ppt
Unit 5.133333333333333333333333333333333.ppt
EventHandling in object oriented programming
JAVA AWT
Event Handling in Java as per university
event-handling.pptx
Mobile Application Development
JAVA UNIT 5.pptx jejsjdkkdkdkjjndjfjfkfjfnfn
Event Handling PRESENTATION AND PROGRAMMING
Yahoo presentation: JavaScript Events
event handling new.ppt
java-programming GUI- Event Handling.pdf
JAVA (CHAPTER 1 EXCEPTION HANDLING) NOTES -PPT
java - topic (event handling notes )1.ppt
Lecture 18
Androd Listeners
Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024

Recently uploaded (20)

PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PPTX
history of c programming in notes for students .pptx
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Patient Appointment Booking in Odoo with online payment
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
Download FL Studio Crack Latest version 2025 ?
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Complete Guide to Website Development in Malaysia for SMEs
PDF
Website Design Services for Small Businesses.pdf
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Design an Analysis of Algorithms II-SECS-1021-03
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
history of c programming in notes for students .pptx
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Weekly report ppt - harsh dattuprasad patel.pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 41
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Patient Appointment Booking in Odoo with online payment
Advanced SystemCare Ultimate Crack + Portable (2025)
Monitoring Stack: Grafana, Loki & Promtail
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Oracle Fusion HCM Cloud Demo for Beginners
iTop VPN Crack Latest Version Full Key 2025
Download FL Studio Crack Latest version 2025 ?
Designing Intelligence for the Shop Floor.pdf
Complete Guide to Website Development in Malaysia for SMEs
Website Design Services for Small Businesses.pdf
Odoo Companies in India – Driving Business Transformation.pdf
Design an Analysis of Algorithms II-SECS-1021-03

Java Event Handling

  • 2. o The Event Handling Process o Event Classes o Semantic Event Handling in Applets o Semantic Event Handling in an Application 
  • 9. WINDOW_OPENED  The event that occurs the first time a window is made visible. WINDOW_CLOSING  The event that occurs as a result of the close icon being selected or Close being selected from the window’s system menu. WINDOW_CLOSED  The event that occurs when the window has been closed. WINDOW_ACTIVATED  The event that occurs when the window is activated— obtains the focus, in other words. When another GUI component has the focus,you could make the window obtain the focus by clicking on it, for
  • 10. WINDOW_DEACTIVATED  The event that occurs when the window is deactivated—loses the focus, in other words. Clicking on another window would cause this event. WINDOW_GAINED_FOCUS  The event that occurs when the window gains the focus. This implies that the window or one of its components will receive keyboard events. WINDOW_LOST_FOCUS  The event that occurs when the window loses the focus. This implies that keyboard events will not be delivered to the window or any of its components. WINDOW_ICONIFIED  The event that occurs when the window is minimized and reduced to an icon. WINDOW_DEICONIFIED  The event that occurs when the window is restored from an icon. WINDOW_STATE_CHANGED  The event that occurs when the window state changes—when it ismaximized or minimized, for instance.
  • 11. processWindowFocusEvent(WindowEvent e) This method is called for any window focus events that arise as long as such events are enabled for the window. processWindowStateEvent(WindowEvent e) This method is called for events arising as a result of the window changing state.
  • 12. processEvent(AWTEvent e) This method is called first for any events that are enabled for the component. If you implement this method and fail to call the base class method, none of the methods for specific groups of events will be called. processFocusEvent(FocusEvent e)  This method will be called for focus events, if they are enabled for the component. processKeyEvent(KeyEvent e) This method will be called for key events, if they are enabled for the component.
  • 13. processMouseEvent(MouseEvent e) This method will be called for mouse button events, if they are enabled for the component. processMouseMotionEvent(MouseEvent e) This method will be called for mouse move and drag events, if they are enabled for the component. processMouseWheelEvent(MouseWheelEvent e) This method will be called for mouse wheel rotation events, if they are enabled for the component
  • 14. The WindowListener Interface The WindowFocusListener Interface The WindowStateListener Interface The MouseListener Interface The MouseMotionListener Interface The MouseWheelListener Interface The KeyListener Interface The FocusListener Interface
  • 16. windowGainedFocus(WindowEvent e)  Called when the window gains the focus such that the window or one of its components will receive keyboard events. windowLostFocus(WindowEvent e) Called when the window loses the focus. After this event, neither the window nor any of its components will receive keyboard events. The WindowStateListener Interface windowStateChanged(WindowEvent e) Called when the window state changes—when it is maximized or iconified.
  • 18. The MouseMotionListener Interface mouseMoved(MouseEvent e)  Called when the mouse is moved within a component mouseDragged(MouseEvent e)  Called when the mouse is moved within a component while a mouse button is held down The MouseWheelListener Interface mouseWheelMoved(MouseWheelEvent e) Called when the mouse wheel is rotated Go
  • 19. The KeyListener Interface This interface defines methods to respond to events arising when a key on the keyboard is pressed or released. keyTyped(KeyEvent e)  Called when a key on the keyboard is pressed and then released keyPressed(KeyEvent e)  Called when a key on the keyboard is pressed keyReleased(KeyEvent e)  Called when a key on the keyboard is released The FocusListener Interface This interface defines methods to respond to a component gaining or losing the focus. focusGained(FocusEvent e)  Called when a component gains the keyboard focus focusLost(FocusEvent e)  Called when a component loses the keyboard focus Go
  • 22. Semantic Event Listeners ActionListener void actionPerformed(ActionEvent e) ItemListener void itemStateChanged(ItemEvent e) AdjustmentListener void adjustmentValueChanged(AdjustmentEvent e) Go