SlideShare a Scribd company logo
1 of 23
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

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
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.
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
Semantic Event Listeners
ActionListener
void actionPerformed(ActionEvent e)
ItemListener
void itemStateChanged(ItemEvent e)
AdjustmentListener
void adjustmentValueChanged(AdjustmentEvent e)
Go
Example

More Related Content

What's hot

Event handling63
Event handling63Event handling63
Event handling63
myrajendra
 
12 High Level UI Event Handling
12 High Level UI Event Handling12 High Level UI Event Handling
12 High Level UI Event Handling
corneliuskoo
 
Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5
sotlsoc
 
Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2
PRN USM
 

What's hot (20)

Unit-3 event handling
Unit-3 event handlingUnit-3 event handling
Unit-3 event handling
 
Event handling
Event handlingEvent handling
Event handling
 
Advance Java Programming(CM5I) Event handling
Advance Java Programming(CM5I) Event handlingAdvance Java Programming(CM5I) Event handling
Advance Java Programming(CM5I) Event handling
 
Event handling63
Event handling63Event handling63
Event handling63
 
Event handling
Event handlingEvent handling
Event handling
 
What is Event
What is EventWhat is Event
What is Event
 
JAVA GUI PART III
JAVA GUI PART IIIJAVA GUI PART III
JAVA GUI PART III
 
Ajp notes-chapter-03
Ajp notes-chapter-03Ajp notes-chapter-03
Ajp notes-chapter-03
 
Swing
SwingSwing
Swing
 
Lecture8 oopj
Lecture8 oopjLecture8 oopj
Lecture8 oopj
 
12 High Level UI Event Handling
12 High Level UI Event Handling12 High Level UI Event Handling
12 High Level UI Event Handling
 
Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5
 
Java gui event
Java gui eventJava gui event
Java gui event
 
Dr Jammi Ashok - Introduction to Java Material (OOPs)
 Dr Jammi Ashok - Introduction to Java Material (OOPs) Dr Jammi Ashok - Introduction to Java Material (OOPs)
Dr Jammi Ashok - Introduction to Java Material (OOPs)
 
Lesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPFLesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPF
 
Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
09events
09events09events
09events
 
25 awt
25 awt25 awt
25 awt
 
Advance Java Programming (CM5I) 2.Swing
Advance Java Programming (CM5I) 2.SwingAdvance Java Programming (CM5I) 2.Swing
Advance Java Programming (CM5I) 2.Swing
 

Viewers also liked (7)

Java programming-Event Handling
Java programming-Event HandlingJava programming-Event Handling
Java programming-Event Handling
 
Awt
AwtAwt
Awt
 
Java awt
Java awtJava awt
Java awt
 
00 swing
00 swing00 swing
00 swing
 
Java session11
Java session11Java session11
Java session11
 
Java AWT
Java AWTJava AWT
Java AWT
 
Applet life cycle
Applet life cycleApplet life cycle
Applet life cycle
 

Similar to Java Event Handling

ITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptxITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptx
udithaisur
 

Similar to Java Event Handling (20)

engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.ppt
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptx
 
Mobile Application Development
Mobile Application DevelopmentMobile Application Development
Mobile Application Development
 
Java
JavaJava
Java
 
AWT
AWT AWT
AWT
 
Yahoo presentation: JavaScript Events
Yahoo presentation: JavaScript EventsYahoo presentation: JavaScript Events
Yahoo presentation: JavaScript Events
 
event handling new.ppt
event handling new.pptevent handling new.ppt
event handling new.ppt
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Androd Listeners
Androd ListenersAndrod Listeners
Androd Listeners
 
Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024
 
Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024
 
ITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptxITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptx
 
java Unit4 chapter1 applets
java Unit4 chapter1 appletsjava Unit4 chapter1 applets
java Unit4 chapter1 applets
 
Unit 6 Java
Unit 6 JavaUnit 6 Java
Unit 6 Java
 
FirefoxOS Window Management
FirefoxOS Window ManagementFirefoxOS Window Management
FirefoxOS Window Management
 
JEDI Slides-Intro2-Chapter20-GUI Event Handling.pdf
JEDI Slides-Intro2-Chapter20-GUI Event Handling.pdfJEDI Slides-Intro2-Chapter20-GUI Event Handling.pdf
JEDI Slides-Intro2-Chapter20-GUI Event Handling.pdf
 
File Handling
File HandlingFile Handling
File Handling
 
Advance java for bscit
Advance java for bscitAdvance java for bscit
Advance java for bscit
 
Voices That Matter: JavaScript Events
Voices That Matter: JavaScript EventsVoices That Matter: JavaScript Events
Voices That Matter: JavaScript Events
 

Recently uploaded

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 

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 
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 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
  • 15.
  • 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.
  • 17.
  • 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
  • 21.
  • 22. Semantic Event Listeners ActionListener void actionPerformed(ActionEvent e) ItemListener void itemStateChanged(ItemEvent e) AdjustmentListener void adjustmentValueChanged(AdjustmentEvent e) Go