SlideShare a Scribd company logo
1 of 27
Event :
An event is an Object that describes a
state change in a Source.
* Some of the activities that causes event
to be generated are :
*Pressing a Button.
*Entering a character through
Key Board.
*Selecting an item form a list etc.
 For implementing event listener we have to
import the following Statement:
import java.awt.event.*;
 Event Handling is the mechanism that
controls the event and decides what should
happen if an event occurs.This mechanism
have the code which is known as event
handler that is executed when an event
occurs. Java Uses the Delegation Event
Model to handle the events.This model
defines the standard mechanism to
generate and handle the events
 Foreground Events:
Those events which require
the direct interaction of user.They are
generated as consequences of a person
interacting with the graphical components in
Graphical User Interface. For example, clicking
on a button, moving the mouse, entering a
character through keyboard,selecting an item
from list, scrolling the page etc.
 Background Events :
Those events that require
the interaction of end user are known as
background events. Operating system
interrupts, hardware or software failure,
timer expires, an operation completion are
the example of background events.
 Input events:
 Input events generally carry three pieces of
information: the event type, the location of
the mouse or pen when the event occurred,
and some modifier button information.The
modifier information includes which
mouse/pen buttons are currently pressed
and whether control, shift, alt or command
keys are also pressed at the time.
 Key events:
 The component peers deliver separate key
events when a user presses and releases
nearly any key. KEY_ACTION and
KEY_ACTION_RELEASE are for the
function and arrow keys, while KEY_PRESS
and KEY_RELEASE are for the remaining
control and alphanumeric keys.
 Mouse events
 The component peers deliver mouse events
when a user presses or releases a mouse
button. Events are also delivered whenever
the mouse moves.
 For example :
 MouseMotionListener interface
define two events:
 When mouse is dragged.
 When mouse is moved.
 Focus events
 The peers deliver focus events when a
component gains (GOT_FOCUS) or
loses(LOST_FOCUS) the input focus. No
default methods are called for the focus
events. They must be dealt with in the
handleEvent() method of the Container of
the component or a subclass of the
component.
 ActionEvent
 The ActionEvent class is the first higher-
level event class. It encapsulates events
that signify that the user is doing
something with a component.When the
user selects a button, list item, or menu
item, or presses the Return key in a text
field, an ActionEvent passes through the
event queue looking for listeners.
 ItemEvent:
 The ItemEvent class is another higher-level
event class. It encapsulates events that occur
when the user selects a component, like
ActionEvent. When the user selects a
checkbox, choice, list item, or checkbox menu
item, an ItemEvent passes through the event
queue looking for listeners. Although there is
only one type of ItemEvent, there are two
subtypes represented by the constants
SELECTED and DE- SELECTED.
 It is simple and well suited to an object-
oriented programming environment.
► An event can only be handled by the
component from which it originated or by
one of the containers of the originating
component.
►In order to handle events, you must either
subclass the component that receives the
event or create a handleEvent() method at
the base container.
 A delegate is better adapted to an object-
oriented language model and is completely
type checked for code reliability.
 Source -The source is an object on which
event occurs. Source is responsible for
providing information of the occurred
event to it's handler. Java provide as with
classes for source object.
 Listener - It is also known as event handler.
Listener is responsible for generating
response to an event.The listener is also an
object. Listener waits until it receives an
event. Once the event is received , the
listener process the event an then returns.
 The User clicks the button and the event is
generated.
 Now the object of concerned event class is
created automatically and information
about the source and the event get
populated with in same object.
 Event object is forwarded to the method of
registered listener class.
 the method is now get executed and
returns.
 In order to design a listener class we have
to develop some listener interfaces.These
Listener interfaces forecast some public
abstract callback methods which must be
implemented by the listener class.
 If you do not implement the any if the
predefined interfaces then your class can
not act as a listener class for a source
object.
 The callback methods represents an event
method. In response to an event java jre
will fire callback method. All such callback
methods are provided in listener interfaces.
Why use Adapter classes?
 Implementing all methods of an interface
takes a lot of work
 Interested in implementing some methods
of the interface only.
 Built-in in Java
 Implement all methods of each listener
interface
 with more than one method.
 Making Simple Calculators By Using Event
Handling:
Event Handling in Java

More Related Content

What's hot

What's hot (20)

JAVA GUI PART I
JAVA GUI PART IJAVA GUI PART I
JAVA GUI PART I
 
Notification android
Notification androidNotification android
Notification android
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
jQuery -Chapter 2 - Selectors and Events
jQuery -Chapter 2 - Selectors and Events jQuery -Chapter 2 - Selectors and Events
jQuery -Chapter 2 - Selectors and Events
 
Event Handling in JAVA
Event Handling in JAVAEvent Handling in JAVA
Event Handling in JAVA
 
Exception handling
Exception handlingException handling
Exception handling
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
Sending emails through PHP
Sending emails through PHPSending emails through PHP
Sending emails through PHP
 
Android notification
Android notificationAndroid notification
Android notification
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
5 collection framework
5 collection framework5 collection framework
5 collection framework
 
Fragment
Fragment Fragment
Fragment
 
interface in c#
interface in c#interface in c#
interface in c#
 
Collections Api - Java
Collections Api - JavaCollections Api - Java
Collections Api - Java
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
 
Event handling
Event handlingEvent handling
Event handling
 
Asp.NET Validation controls
Asp.NET Validation controlsAsp.NET Validation controls
Asp.NET Validation controls
 
JavaScript Fetch API
JavaScript Fetch APIJavaScript Fetch API
JavaScript Fetch API
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
 

Viewers also liked

Java programming-Event Handling
Java programming-Event HandlingJava programming-Event Handling
Java programming-Event HandlingJava Programming
 
tL20 event handling
tL20 event handlingtL20 event handling
tL20 event handlingteach4uin
 
Java Event Handling
Java Event HandlingJava Event Handling
Java Event HandlingShraddha
 
Basic Event Listener
Basic Event ListenerBasic Event Listener
Basic Event Listenerkunemata
 
๋Java Programming [7/12] : GUI Event Handling
๋Java Programming [7/12] : GUI Event Handling๋Java Programming [7/12] : GUI Event Handling
๋Java Programming [7/12] : GUI Event HandlingIMC Institute
 
Learning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security APILearning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security APIcaswenson
 
Java session11
Java session11Java session11
Java session11Niit Care
 
Concurrency Utilities in Java 8
Concurrency Utilities in Java 8Concurrency Utilities in Java 8
Concurrency Utilities in Java 8Martin Toshev
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.David Gómez García
 
Learning Java 3 – Threads and Synchronization
Learning Java 3 – Threads and SynchronizationLearning Java 3 – Threads and Synchronization
Learning Java 3 – Threads and Synchronizationcaswenson
 
Working With Concurrency In Java 8
Working With Concurrency In Java 8Working With Concurrency In Java 8
Working With Concurrency In Java 8Heartin Jacob
 
Java Thread Synchronization
Java Thread SynchronizationJava Thread Synchronization
Java Thread SynchronizationBenj Del Mundo
 

Viewers also liked (17)

Java programming-Event Handling
Java programming-Event HandlingJava programming-Event Handling
Java programming-Event Handling
 
tL20 event handling
tL20 event handlingtL20 event handling
tL20 event handling
 
Java Event Handling
Java Event HandlingJava Event Handling
Java Event Handling
 
Basic Event Listener
Basic Event ListenerBasic Event Listener
Basic Event Listener
 
Event handling
Event handlingEvent handling
Event handling
 
๋Java Programming [7/12] : GUI Event Handling
๋Java Programming [7/12] : GUI Event Handling๋Java Programming [7/12] : GUI Event Handling
๋Java Programming [7/12] : GUI Event Handling
 
Learning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security APILearning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security API
 
Java 8 parallel stream
Java 8 parallel streamJava 8 parallel stream
Java 8 parallel stream
 
Java session11
Java session11Java session11
Java session11
 
Concurrency Utilities in Java 8
Concurrency Utilities in Java 8Concurrency Utilities in Java 8
Concurrency Utilities in Java 8
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
 
Learning Java 3 – Threads and Synchronization
Learning Java 3 – Threads and SynchronizationLearning Java 3 – Threads and Synchronization
Learning Java 3 – Threads and Synchronization
 
Working With Concurrency In Java 8
Working With Concurrency In Java 8Working With Concurrency In Java 8
Working With Concurrency In Java 8
 
Java Thread Synchronization
Java Thread SynchronizationJava Thread Synchronization
Java Thread Synchronization
 
Java 8 Streams
Java 8 StreamsJava 8 Streams
Java 8 Streams
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Awt
AwtAwt
Awt
 

Similar to Event Handling in Java

Ajp notes-chapter-03
Ajp notes-chapter-03Ajp notes-chapter-03
Ajp notes-chapter-03Ankit Dubey
 
ITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptxITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptxudithaisur
 
Advance Java Programming(CM5I) Event handling
Advance Java Programming(CM5I) Event handlingAdvance Java Programming(CM5I) Event handling
Advance Java Programming(CM5I) Event handlingPayal Dungarwal
 
Java gui event
Java gui eventJava gui event
Java gui eventSoftNutx
 
event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptxusvirat1805
 
Unit-3 event handling
Unit-3 event handlingUnit-3 event handling
Unit-3 event handlingAmol Gaikwad
 
event handling new.ppt
event handling new.pptevent handling new.ppt
event handling new.pptusama537223
 
Chap - 2 - Event Handling.pptx
Chap - 2 - Event Handling.pptxChap - 2 - Event Handling.pptx
Chap - 2 - Event Handling.pptxTadeseBeyene
 
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)jammiashok123
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptsharanyak0721
 
File Handling
File HandlingFile Handling
File HandlingSohanur63
 
Event+driven+programming key+features
Event+driven+programming key+featuresEvent+driven+programming key+features
Event+driven+programming key+featuresFaisal Aziz
 
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. 2024nehakumari0xf
 
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. 2024kashyapneha2809
 
Java eventhandling
Java eventhandlingJava eventhandling
Java eventhandlingArati Gadgil
 

Similar to Event Handling in Java (20)

Event handling in Java(part 1)
Event handling in Java(part 1)Event handling in Java(part 1)
Event handling in Java(part 1)
 
Unit 6 Java
Unit 6 JavaUnit 6 Java
Unit 6 Java
 
Ajp notes-chapter-03
Ajp notes-chapter-03Ajp notes-chapter-03
Ajp notes-chapter-03
 
What is Event
What is EventWhat is Event
What is Event
 
ITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptxITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptx
 
Advance Java Programming(CM5I) Event handling
Advance Java Programming(CM5I) Event handlingAdvance Java Programming(CM5I) Event handling
Advance Java Programming(CM5I) Event handling
 
Java gui event
Java gui eventJava gui event
Java gui event
 
event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptx
 
Unit-3 event handling
Unit-3 event handlingUnit-3 event handling
Unit-3 event handling
 
event handling new.ppt
event handling new.pptevent handling new.ppt
event handling new.ppt
 
Chap - 2 - Event Handling.pptx
Chap - 2 - Event Handling.pptxChap - 2 - Event Handling.pptx
Chap - 2 - Event Handling.pptx
 
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)
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.ppt
 
JAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
JAVA PROGRAMMING- GUI Programming with Swing - The Swing ButtonsJAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
JAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
 
File Handling
File HandlingFile Handling
File Handling
 
Event+driven+programming key+features
Event+driven+programming key+featuresEvent+driven+programming key+features
Event+driven+programming key+features
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
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
 
Java eventhandling
Java eventhandlingJava eventhandling
Java eventhandling
 

Recently uploaded

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...panagenda
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
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.pdfWave PLM
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
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 ApplicationsAlberto González Trastoy
 
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.comFatema Valibhai
 
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.jsAndolasoft Inc
 
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.pdfkalichargn70th171
 
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.docxComplianceQuest1
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
+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
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
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 ...harshavardhanraghave
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
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 ...OnePlan Solutions
 

Recently uploaded (20)

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...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
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
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
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
 
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 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
 
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
 
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
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
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
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
+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...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
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 ...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
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 ...
 

Event Handling in Java

  • 1.
  • 2. Event : An event is an Object that describes a state change in a Source. * Some of the activities that causes event to be generated are : *Pressing a Button. *Entering a character through Key Board. *Selecting an item form a list etc.
  • 3.
  • 4.
  • 5.  For implementing event listener we have to import the following Statement: import java.awt.event.*;
  • 6.  Event Handling is the mechanism that controls the event and decides what should happen if an event occurs.This mechanism have the code which is known as event handler that is executed when an event occurs. Java Uses the Delegation Event Model to handle the events.This model defines the standard mechanism to generate and handle the events
  • 7.  Foreground Events: Those events which require the direct interaction of user.They are generated as consequences of a person interacting with the graphical components in Graphical User Interface. For example, clicking on a button, moving the mouse, entering a character through keyboard,selecting an item from list, scrolling the page etc.
  • 8.  Background Events : Those events that require the interaction of end user are known as background events. Operating system interrupts, hardware or software failure, timer expires, an operation completion are the example of background events.
  • 9.
  • 10.  Input events:  Input events generally carry three pieces of information: the event type, the location of the mouse or pen when the event occurred, and some modifier button information.The modifier information includes which mouse/pen buttons are currently pressed and whether control, shift, alt or command keys are also pressed at the time.
  • 11.  Key events:  The component peers deliver separate key events when a user presses and releases nearly any key. KEY_ACTION and KEY_ACTION_RELEASE are for the function and arrow keys, while KEY_PRESS and KEY_RELEASE are for the remaining control and alphanumeric keys.
  • 12.  Mouse events  The component peers deliver mouse events when a user presses or releases a mouse button. Events are also delivered whenever the mouse moves.
  • 13.  For example :  MouseMotionListener interface define two events:  When mouse is dragged.  When mouse is moved.
  • 14.  Focus events  The peers deliver focus events when a component gains (GOT_FOCUS) or loses(LOST_FOCUS) the input focus. No default methods are called for the focus events. They must be dealt with in the handleEvent() method of the Container of the component or a subclass of the component.
  • 15.  ActionEvent  The ActionEvent class is the first higher- level event class. It encapsulates events that signify that the user is doing something with a component.When the user selects a button, list item, or menu item, or presses the Return key in a text field, an ActionEvent passes through the event queue looking for listeners.
  • 16.  ItemEvent:  The ItemEvent class is another higher-level event class. It encapsulates events that occur when the user selects a component, like ActionEvent. When the user selects a checkbox, choice, list item, or checkbox menu item, an ItemEvent passes through the event queue looking for listeners. Although there is only one type of ItemEvent, there are two subtypes represented by the constants SELECTED and DE- SELECTED.
  • 17.  It is simple and well suited to an object- oriented programming environment.
  • 18. ► An event can only be handled by the component from which it originated or by one of the containers of the originating component. ►In order to handle events, you must either subclass the component that receives the event or create a handleEvent() method at the base container.
  • 19.  A delegate is better adapted to an object- oriented language model and is completely type checked for code reliability.
  • 20.  Source -The source is an object on which event occurs. Source is responsible for providing information of the occurred event to it's handler. Java provide as with classes for source object.
  • 21.  Listener - It is also known as event handler. Listener is responsible for generating response to an event.The listener is also an object. Listener waits until it receives an event. Once the event is received , the listener process the event an then returns.
  • 22.  The User clicks the button and the event is generated.  Now the object of concerned event class is created automatically and information about the source and the event get populated with in same object.  Event object is forwarded to the method of registered listener class.  the method is now get executed and returns.
  • 23.  In order to design a listener class we have to develop some listener interfaces.These Listener interfaces forecast some public abstract callback methods which must be implemented by the listener class.  If you do not implement the any if the predefined interfaces then your class can not act as a listener class for a source object.
  • 24.  The callback methods represents an event method. In response to an event java jre will fire callback method. All such callback methods are provided in listener interfaces.
  • 25. Why use Adapter classes?  Implementing all methods of an interface takes a lot of work  Interested in implementing some methods of the interface only.
  • 26.  Built-in in Java  Implement all methods of each listener interface  with more than one method.  Making Simple Calculators By Using Event Handling: