The document discusses Java event handling and the delegation event model. It describes key concepts like events, sources that generate events, and listeners that handle events. It provides examples of registering components as listeners and implementing listener interfaces. The delegation event model joins sources, listeners, and events by notifying listeners when sources generate events.
Event handling in UI components involves 3 steps: 1) the hardware recognizes an event, 2) the software is notified, 3) a message is sent to the application. Listeners must be implemented to accept events. Command and Item objects contain event information. Events are processed by adding Commands to components and adding listeners. Common listeners are CommandListener and ItemStateListener.
Ch5 intent broadcast receivers adapters and internetShih-Hsiang Lin
The document provides an overview of intents, broadcast receivers, adapters, and using internet resources in Android applications. It discusses how intents allow interaction between applications through message passing and how they can be used to start activities, broadcast events, and start services. It covers explicit and implicit intents, returning results from activities, and registering broadcast receivers and activities to handle intents through intent filters. The document also discusses linkify for making links in text views, broadcasting events with intents, and registering broadcast receivers in the manifest.
Event-driven programming is a programming paradigm where the flow of the program is determined by events such as user input. In event-driven programming, an event trigger causes an event handler method to execute. Common event triggers include user interactions like mouse clicks or key presses. This paradigm is well-suited for graphical user interfaces that allow users to interact with and control the flow of the program.
Event driven programming is commonly used for GUI applications where events like button clicks or text changes trigger event handler functions. Key aspects include event handlers that contain code to execute in response to events, trigger functions that determine which handler to run, and event loops that constantly check for events. This approach provides flexibility by allowing programmers to control where code runs and what specific user actions it will respond to.
This document discusses event-driven programming and different event-driven programming patterns. It covers structured programming vs event-driven programming, common event patterns like publish/subscribe, subject/observer, event/handler, and signal/slot. It also discusses asynchronous vs synchronous programming, interrupts, design patterns for event programming, and best practices for implementing event-driven code.
Event and signal driven programming techniquesElizabeth Smith
Given at Zendcon 2011 this is a computer theory heavy, code absent look at event driven programming design patterns and techniques in the programming community
The document describes different types of sensors available on Android devices including motion sensors like accelerometers and gyroscopes, position sensors like orientation sensors, and environment sensors such as temperature, light, and pressure sensors. For each sensor type, it provides the hardware or software implementation, what physical property it measures, and common uses. It also indicates which sensor types have been available since early Android versions and which were introduced in later API levels.
The document discusses Java event handling and the delegation event model. It describes key concepts like events, sources that generate events, and listeners that handle events. It provides examples of registering components as listeners and implementing listener interfaces. The delegation event model joins sources, listeners, and events by notifying listeners when sources generate events.
Event handling in UI components involves 3 steps: 1) the hardware recognizes an event, 2) the software is notified, 3) a message is sent to the application. Listeners must be implemented to accept events. Command and Item objects contain event information. Events are processed by adding Commands to components and adding listeners. Common listeners are CommandListener and ItemStateListener.
Ch5 intent broadcast receivers adapters and internetShih-Hsiang Lin
The document provides an overview of intents, broadcast receivers, adapters, and using internet resources in Android applications. It discusses how intents allow interaction between applications through message passing and how they can be used to start activities, broadcast events, and start services. It covers explicit and implicit intents, returning results from activities, and registering broadcast receivers and activities to handle intents through intent filters. The document also discusses linkify for making links in text views, broadcasting events with intents, and registering broadcast receivers in the manifest.
Event-driven programming is a programming paradigm where the flow of the program is determined by events such as user input. In event-driven programming, an event trigger causes an event handler method to execute. Common event triggers include user interactions like mouse clicks or key presses. This paradigm is well-suited for graphical user interfaces that allow users to interact with and control the flow of the program.
Event driven programming is commonly used for GUI applications where events like button clicks or text changes trigger event handler functions. Key aspects include event handlers that contain code to execute in response to events, trigger functions that determine which handler to run, and event loops that constantly check for events. This approach provides flexibility by allowing programmers to control where code runs and what specific user actions it will respond to.
This document discusses event-driven programming and different event-driven programming patterns. It covers structured programming vs event-driven programming, common event patterns like publish/subscribe, subject/observer, event/handler, and signal/slot. It also discusses asynchronous vs synchronous programming, interrupts, design patterns for event programming, and best practices for implementing event-driven code.
Event and signal driven programming techniquesElizabeth Smith
Given at Zendcon 2011 this is a computer theory heavy, code absent look at event driven programming design patterns and techniques in the programming community
The document describes different types of sensors available on Android devices including motion sensors like accelerometers and gyroscopes, position sensors like orientation sensors, and environment sensors such as temperature, light, and pressure sensors. For each sensor type, it provides the hardware or software implementation, what physical property it measures, and common uses. It also indicates which sensor types have been available since early Android versions and which were introduced in later API levels.
The document discusses Java event handling and various listener interfaces. It describes the delegation event model where an event source generates an event and sends it to registered listeners. It outlines common listener interfaces like ActionListener, ItemListener, KeyListener, MouseListener, and WindowListener. It provides details on the methods in each interface and how to write classes that implement the listener interfaces.
The document discusses event handling in Java. It describes how events are generated from user interactions with GUI components and handled via the delegation event model. This model involves events, event sources that generate events, and event listeners that receive and process events. The document lists some important event classes like ActionEvent and MouseEvent, and listener interfaces. It also provides details on how to register listeners with sources and implement event handling in classes.
This document provides an overview of event handling in Java. It discusses the delegation event model where a source generates an event and sends it to one or more listeners. It describes event sources, event listeners, common event classes like ActionEvent, MouseEvent, and KeyEvent. It explains the roles of sources that generate events, listeners that receive event notifications, and event classes that represent specific types of events.
This document provides an overview of event handling in Java. It discusses key concepts like events, event sources, event listeners, and different types of events like action events, item events, key events, mouse events, and window events. For each event type, it describes the relevant listener interface and event class, including their common methods. It explains how events are generated by sources and handled by registered listener objects using the delegation event model in Java.
Event handling in Java uses the delegation event model. There are two main types of events - foreground events which require direct user interaction, and background events which do not. The delegation model defines key participants in event handling - the source which generates the event, and the listener which processes the event. Common event classes in Java include ActionEvent, WindowEvent, AdjustmentEvent, and KeyEvent. Listener interfaces define callback methods for the different event types.
1. An event describes a change in state of an object and is generated from user interaction with GUI components like buttons, mouse movement, keyboard entry etc.
2. There are two types of events - foreground events from direct user interaction and background events from system processes.
3. Event handling is the mechanism that controls how programs respond to events using event handlers (listener objects) that contain code to execute when an event occurs. The delegation event model defines how events are generated and handled in Java.
Java Programming :Event Handling(Types of Events)simmis5
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.
The document discusses how event listeners in Swing handle user events in Java GUI applications. It explains that classes need to implement listener interfaces to respond to specific event types. When a component is associated with a listener object, the listener will receive notifications for that event type. The listener must contain handler methods that are called when events occur. Details like the event source can be extracted from the event object passed to the handler.
This document discusses event handling in Java. It describes the delegation event model where a source generates an event and sends it to one or more listeners. It outlines several common listener interfaces like ActionListener, ItemListener, KeyListener, MouseListener, and WindowListener. For each interface it provides the listener methods and describes how to write an event handler class to implement the interface. It also discusses the classes for different event types like ActionEvent, ItemEvent, KeyEvent, and MouseEvent.
This document discusses event handling in Java. It describes the delegation event model where a source generates an event and sends it to one or more listeners. It outlines several common listener interfaces like ActionListener, ItemListener, KeyListener, MouseListener, and WindowListener. For each interface it provides the listener methods and describes how to write an event handler class to implement the interface. It also discusses the classes for different event types like ActionEvent, ItemEvent, KeyEvent, and MouseEvent.
This document discusses event handling in Java. It provides an introduction to event handling, the delegation event model, common event packages and classes in Java. It describes key concepts like events, event sources, event listeners, and how they interact in the delegation model. It provides examples of specific event classes like KeyEvent, ActionEvent, ItemEvent and the corresponding listener interfaces. It also demonstrates sample code for common listeners.
This document discusses event handling in Java GUI programming. It defines an event as user interaction with a GUI component. Events have sources that trigger them and listeners that process them via event handlers. Common event listener interfaces include ActionListener, ComponentListener, and FocusListener. The event handling process involves determining the event source and type, creating an event object, and invoking the appropriate listener method. Examples are given of sources that can trigger events and assignments are provided to practice event handling.
This document discusses event handling in Java. It defines events as changes in the state of an object and categorizes them as foreground or background events. It explains that event handling uses a delegation model with sources that generate events and listeners that handle them. It provides an example of handling action events from buttons by implementing an ActionListener interface and attaching it to the buttons. The example displays text indicating which button was clicked.
The document discusses Java AWT event handling and graphics. It covers key concepts like events, event classes, event handling process, commonly used event listeners and adapter classes. It also covers AWT containers, layout managers, menu classes, graphics classes and how to work with frames and graphics in Java. The document is intended to teach programming in Java and is part of a larger unit on AWT.
Event handling in ASP.NET involves responding to events that occur at the client or server. Events raised at the client are handled at the server. When an event like a button click occurs, the browser posts the event to the server, which checks for an associated event handler method to execute. Common events include page and control loading, data binding, and user interaction events. Event handlers are coded to respond to specific events and take action. Controls generate events that can be handled using attributes and event handler methods.
An event-driven program relies on events to trigger responses rather than actively polling for user input. Older programs used polling which involved continuously checking for user actions in a loop, wasting CPU resources. Event-driven programs address this by using listeners that wait passively for events from sources like user interactions. When an event occurs, the appropriate listener receives and handles the event without wasting resources on empty polling loops.
The document discusses event handling and layouts in Java. It describes what events are, the delegation event model used in Java for handling events, and common event and listener classes. It also provides examples of using buttons and event handling in both AWT and Swing. The section about layouts states that layout managers automatically position and size components within containers.
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesChristina Lin
Traditionally, dealing with real-time data pipelines has involved significant overhead, even for straightforward tasks like data transformation or masking. However, in this talk, we’ll venture into the dynamic realm of WebAssembly (WASM) and discover how it can revolutionize the creation of stateless streaming pipelines within a Kafka (Redpanda) broker. These pipelines are adept at managing low-latency, high-data-volume scenarios.
The document discusses Java event handling and various listener interfaces. It describes the delegation event model where an event source generates an event and sends it to registered listeners. It outlines common listener interfaces like ActionListener, ItemListener, KeyListener, MouseListener, and WindowListener. It provides details on the methods in each interface and how to write classes that implement the listener interfaces.
The document discusses event handling in Java. It describes how events are generated from user interactions with GUI components and handled via the delegation event model. This model involves events, event sources that generate events, and event listeners that receive and process events. The document lists some important event classes like ActionEvent and MouseEvent, and listener interfaces. It also provides details on how to register listeners with sources and implement event handling in classes.
This document provides an overview of event handling in Java. It discusses the delegation event model where a source generates an event and sends it to one or more listeners. It describes event sources, event listeners, common event classes like ActionEvent, MouseEvent, and KeyEvent. It explains the roles of sources that generate events, listeners that receive event notifications, and event classes that represent specific types of events.
This document provides an overview of event handling in Java. It discusses key concepts like events, event sources, event listeners, and different types of events like action events, item events, key events, mouse events, and window events. For each event type, it describes the relevant listener interface and event class, including their common methods. It explains how events are generated by sources and handled by registered listener objects using the delegation event model in Java.
Event handling in Java uses the delegation event model. There are two main types of events - foreground events which require direct user interaction, and background events which do not. The delegation model defines key participants in event handling - the source which generates the event, and the listener which processes the event. Common event classes in Java include ActionEvent, WindowEvent, AdjustmentEvent, and KeyEvent. Listener interfaces define callback methods for the different event types.
1. An event describes a change in state of an object and is generated from user interaction with GUI components like buttons, mouse movement, keyboard entry etc.
2. There are two types of events - foreground events from direct user interaction and background events from system processes.
3. Event handling is the mechanism that controls how programs respond to events using event handlers (listener objects) that contain code to execute when an event occurs. The delegation event model defines how events are generated and handled in Java.
Java Programming :Event Handling(Types of Events)simmis5
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.
The document discusses how event listeners in Swing handle user events in Java GUI applications. It explains that classes need to implement listener interfaces to respond to specific event types. When a component is associated with a listener object, the listener will receive notifications for that event type. The listener must contain handler methods that are called when events occur. Details like the event source can be extracted from the event object passed to the handler.
This document discusses event handling in Java. It describes the delegation event model where a source generates an event and sends it to one or more listeners. It outlines several common listener interfaces like ActionListener, ItemListener, KeyListener, MouseListener, and WindowListener. For each interface it provides the listener methods and describes how to write an event handler class to implement the interface. It also discusses the classes for different event types like ActionEvent, ItemEvent, KeyEvent, and MouseEvent.
This document discusses event handling in Java. It describes the delegation event model where a source generates an event and sends it to one or more listeners. It outlines several common listener interfaces like ActionListener, ItemListener, KeyListener, MouseListener, and WindowListener. For each interface it provides the listener methods and describes how to write an event handler class to implement the interface. It also discusses the classes for different event types like ActionEvent, ItemEvent, KeyEvent, and MouseEvent.
This document discusses event handling in Java. It provides an introduction to event handling, the delegation event model, common event packages and classes in Java. It describes key concepts like events, event sources, event listeners, and how they interact in the delegation model. It provides examples of specific event classes like KeyEvent, ActionEvent, ItemEvent and the corresponding listener interfaces. It also demonstrates sample code for common listeners.
This document discusses event handling in Java GUI programming. It defines an event as user interaction with a GUI component. Events have sources that trigger them and listeners that process them via event handlers. Common event listener interfaces include ActionListener, ComponentListener, and FocusListener. The event handling process involves determining the event source and type, creating an event object, and invoking the appropriate listener method. Examples are given of sources that can trigger events and assignments are provided to practice event handling.
This document discusses event handling in Java. It defines events as changes in the state of an object and categorizes them as foreground or background events. It explains that event handling uses a delegation model with sources that generate events and listeners that handle them. It provides an example of handling action events from buttons by implementing an ActionListener interface and attaching it to the buttons. The example displays text indicating which button was clicked.
The document discusses Java AWT event handling and graphics. It covers key concepts like events, event classes, event handling process, commonly used event listeners and adapter classes. It also covers AWT containers, layout managers, menu classes, graphics classes and how to work with frames and graphics in Java. The document is intended to teach programming in Java and is part of a larger unit on AWT.
Event handling in ASP.NET involves responding to events that occur at the client or server. Events raised at the client are handled at the server. When an event like a button click occurs, the browser posts the event to the server, which checks for an associated event handler method to execute. Common events include page and control loading, data binding, and user interaction events. Event handlers are coded to respond to specific events and take action. Controls generate events that can be handled using attributes and event handler methods.
An event-driven program relies on events to trigger responses rather than actively polling for user input. Older programs used polling which involved continuously checking for user actions in a loop, wasting CPU resources. Event-driven programs address this by using listeners that wait passively for events from sources like user interactions. When an event occurs, the appropriate listener receives and handles the event without wasting resources on empty polling loops.
The document discusses event handling and layouts in Java. It describes what events are, the delegation event model used in Java for handling events, and common event and listener classes. It also provides examples of using buttons and event handling in both AWT and Swing. The section about layouts states that layout managers automatically position and size components within containers.
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesChristina Lin
Traditionally, dealing with real-time data pipelines has involved significant overhead, even for straightforward tasks like data transformation or masking. However, in this talk, we’ll venture into the dynamic realm of WebAssembly (WASM) and discover how it can revolutionize the creation of stateless streaming pipelines within a Kafka (Redpanda) broker. These pipelines are adept at managing low-latency, high-data-volume scenarios.
Using recycled concrete aggregates (RCA) for pavements is crucial to achieving sustainability. Implementing RCA for new pavement can minimize carbon footprint, conserve natural resources, reduce harmful emissions, and lower life cycle costs. Compared to natural aggregate (NA), RCA pavement has fewer comprehensive studies and sustainability assessments.
A review on techniques and modelling methodologies used for checking electrom...nooriasukmaningtyas
The proper function of the integrated circuit (IC) in an inhibiting electromagnetic environment has always been a serious concern throughout the decades of revolution in the world of electronics, from disjunct devices to today’s integrated circuit technology, where billions of transistors are combined on a single chip. The automotive industry and smart vehicles in particular, are confronting design issues such as being prone to electromagnetic interference (EMI). Electronic control devices calculate incorrect outputs because of EMI and sensors give misleading values which can prove fatal in case of automotives. In this paper, the authors have non exhaustively tried to review research work concerned with the investigation of EMI in ICs and prediction of this EMI using various modelling methodologies and measurement setups.
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSIJNSA Journal
The smart irrigation system represents an innovative approach to optimize water usage in agricultural and landscaping practices. The integration of cutting-edge technologies, including sensors, actuators, and data analysis, empowers this system to provide accurate monitoring and control of irrigation processes by leveraging real-time environmental conditions. The main objective of a smart irrigation system is to optimize water efficiency, minimize expenses, and foster the adoption of sustainable water management methods. This paper conducts a systematic risk assessment by exploring the key components/assets and their functionalities in the smart irrigation system. The crucial role of sensors in gathering data on soil moisture, weather patterns, and plant well-being is emphasized in this system. These sensors enable intelligent decision-making in irrigation scheduling and water distribution, leading to enhanced water efficiency and sustainable water management practices. Actuators enable automated control of irrigation devices, ensuring precise and targeted water delivery to plants. Additionally, the paper addresses the potential threat and vulnerabilities associated with smart irrigation systems. It discusses limitations of the system, such as power constraints and computational capabilities, and calculates the potential security risks. The paper suggests possible risk treatment methods for effective secure system operation. In conclusion, the paper emphasizes the significant benefits of implementing smart irrigation systems, including improved water conservation, increased crop yield, and reduced environmental impact. Additionally, based on the security analysis conducted, the paper recommends the implementation of countermeasures and security approaches to address vulnerabilities and ensure the integrity and reliability of the system. By incorporating these measures, smart irrigation technology can revolutionize water management practices in agriculture, promoting sustainability, resource efficiency, and safeguarding against potential security threats.
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTjpsjournal1
The rivalry between prominent international actors for dominance over Central Asia's hydrocarbon
reserves and the ancient silk trade route, along with China's diplomatic endeavours in the area, has been
referred to as the "New Great Game." This research centres on the power struggle, considering
geopolitical, geostrategic, and geoeconomic variables. Topics including trade, political hegemony, oil
politics, and conventional and nontraditional security are all explored and explained by the researcher.
Using Mackinder's Heartland, Spykman Rimland, and Hegemonic Stability theories, examines China's role
in Central Asia. This study adheres to the empirical epistemological method and has taken care of
objectivity. This study analyze primary and secondary research documents critically to elaborate role of
china’s geo economic outreach in central Asian countries and its future prospect. China is thriving in trade,
pipeline politics, and winning states, according to this study, thanks to important instruments like the
Shanghai Cooperation Organisation and the Belt and Road Economic Initiative. According to this study,
China is seeing significant success in commerce, pipeline politics, and gaining influence on other
governments. This success may be attributed to the effective utilisation of key tools such as the Shanghai
Cooperation Organisation and the Belt and Road Economic Initiative.
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...IJECEIAES
Climate change's impact on the planet forced the United Nations and governments to promote green energies and electric transportation. The deployments of photovoltaic (PV) and electric vehicle (EV) systems gained stronger momentum due to their numerous advantages over fossil fuel types. The advantages go beyond sustainability to reach financial support and stability. The work in this paper introduces the hybrid system between PV and EV to support industrial and commercial plants. This paper covers the theoretical framework of the proposed hybrid system including the required equation to complete the cost analysis when PV and EV are present. In addition, the proposed design diagram which sets the priorities and requirements of the system is presented. The proposed approach allows setup to advance their power stability, especially during power outages. The presented information supports researchers and plant owners to complete the necessary analysis while promoting the deployment of clean energy. The result of a case study that represents a dairy milk farmer supports the theoretical works and highlights its advanced benefits to existing plants. The short return on investment of the proposed approach supports the paper's novelty approach for the sustainable electrical system. In addition, the proposed system allows for an isolated power setup without the need for a transmission line which enhances the safety of the electrical network
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELgerogepatton
As digital technology becomes more deeply embedded in power systems, protecting the communication
networks of Smart Grids (SG) has emerged as a critical concern. Distributed Network Protocol 3 (DNP3)
represents a multi-tiered application layer protocol extensively utilized in Supervisory Control and Data
Acquisition (SCADA)-based smart grids to facilitate real-time data gathering and control functionalities.
Robust Intrusion Detection Systems (IDS) are necessary for early threat detection and mitigation because
of the interconnection of these networks, which makes them vulnerable to a variety of cyberattacks. To
solve this issue, this paper develops a hybrid Deep Learning (DL) model specifically designed for intrusion
detection in smart grids. The proposed approach is a combination of the Convolutional Neural Network
(CNN) and the Long-Short-Term Memory algorithms (LSTM). We employed a recent intrusion detection
dataset (DNP3), which focuses on unauthorized commands and Denial of Service (DoS) cyberattacks, to
train and test our model. The results of our experiments show that our CNN-LSTM method is much better
at finding smart grid intrusions than other deep learning algorithms used for classification. In addition,
our proposed approach improves accuracy, precision, recall, and F1 score, achieving a high detection
accuracy rate of 99.50%.
Advanced control scheme of doubly fed induction generator for wind turbine us...IJECEIAES
This paper describes a speed control device for generating electrical energy on an electricity network based on the doubly fed induction generator (DFIG) used for wind power conversion systems. At first, a double-fed induction generator model was constructed. A control law is formulated to govern the flow of energy between the stator of a DFIG and the energy network using three types of controllers: proportional integral (PI), sliding mode controller (SMC) and second order sliding mode controller (SOSMC). Their different results in terms of power reference tracking, reaction to unexpected speed fluctuations, sensitivity to perturbations, and resilience against machine parameter alterations are compared. MATLAB/Simulink was used to conduct the simulations for the preceding study. Multiple simulations have shown very satisfying results, and the investigations demonstrate the efficacy and power-enhancing capabilities of the suggested control system.
We have compiled the most important slides from each speaker's presentation. This year’s compilation, available for free, captures the key insights and contributions shared during the DfMAy 2024 conference.
3. Events and Listeners
In event-driven programming, code is executed upon
activation of events
An event can be defined as a type of signal to the program that
something has happened
The event is generated by external user actions such as:
Moving the mouse
Clicking the button
Pressing a key
Sliding the scrollbar
Choosing an item from a menu
Events are responded to by event listeners
4. Event Handling Model
• To process an event
– Register an event listener
– Implement event handler
• Method that is called in response to an event
• Each event handling interface has one or more event
handling methods that must be defined
5. The Event Handling process
When an event is triggered, the JAVA runtime first
determines its source and type
If a listener for this type of event is registered with the
source, an event object is created
For each listener to this type of an event
The JAVA runtime invokes the appropriate event handling
method to the listener and passes the event object as the
parameter
6. Selected User Actions
User Action
Click a button
Select a new item
Select an item from a List
Window opened, closed
Mouse pressed, released
Key released, pressed
Event Type Generated
ActionEvent
ItemEvent, ActionEvent
ListSelectionEvent
WindowEvent
MouseEvent
KeyEvent
Source Object
JButton
JComboBox
JList
Window
MouseEvent
KeyEvent
8. Event Listener and Action Listener
• An Event Listener, once set to an applet object waits for some
action to be performed on it
– It mouse click, mouse hover, pressing of keys, click of
button, etc
• ActionListener is an interface that could be implemented in
order to determine how certain event should be handled
• When implementing an interface, all methods in that interface
should be implemented, ActionListener interface has one
method to implement named actionPerformed()
9. How to Implement a Listener Interface
Use the implements keyword in the class declaration
Register the object as a listener for a component’s event, using
the component’s addXListener method. (where X is the type of
event).
Declare and fully define all methods for the interface that you
are implementing
10. Three Steps of Event Handling
Prepare to accept events
• import package java.awt.event
Start listening for events
• include appropriate methods
Respond to events
• implement appropriate abstract method
11. Prepare to accept events
• Import package java.awt.event
• Applet manifests its desire to accept events by promising to
“implement” certain methods
• Example:
– “ActionListener” for Button events
– “AdjustmentListener” for Scrollbar events
12. Start listening for events
• To make the applet “listen” to a particular event, include the
appropriate “addxxxListener”.
• Examples:
addActionListener(this)
– shows that the applet is interested in listening to events
generated by the pushing of a certain button
addAdjustmentListener(this)
– shows that the applet is interested in listening to events
generated by the sliding of a certain scroll bar
13. Respond to events
• The appropriate abstract methods are implemented.
• Example:
– actionPerformed() is automatically called whenever the user
clicks the button
• Thus, implement actionPerformed() to respond to the button event
– adjustmentValueChanged() is automatically invoked whenever
the user slides the scroll bar thumb
• So adjustmentValueChanged() needs to be implemented
• In actionPerformed(ActionEvent evt), ActionEvent is
a class in java.awt.event
14. ActionEvent
In Java, most components have a special event called an
ActionEvent
This is loosely speaking the most common or canonical
event for that component
A good example is a click for a button
To have any component listen for ActionEvents, you must
register the component with an ActionListener
– e.g. button.addActionListener(new MyAL());
15. ActionPerformed
The actionPerformed method has the following signature:
» void actionPerformed(ActionEvent)
The object of type ActionEvent passed to the event
handler is used to query information about the event
Some common methods are:
getSource()
object reference to component generating event
getActionCommand()
some text associated with event (text on button, etc)