Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Interview-Questions Java event delegation model
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


samar
Java event delegation model
1 Answer(s)      4 years and 2 months ago
Posted in : Java Interview Questions


What is the highest-level event class of the event-delegation model?

Advertisement
View Answers

April 12, 2012 at 2:03 PM


Event delegation model has 3 components these are Event,Listener and Source..

Events

In the delegation model, an event is an object that describes a state change in a source. Event be generated as a consequence of a person interacting with the elements in a graphical user interface. Some of the activities that cause events to be generated are pressing a button, entering a character via the keyboard, selecting an item in a list, and clicking the mouse. Events may also occur that are not directly caused by interactions with a user interface like an event may be generated when a timer expires, a counter exceeds a value, a software or hardware failure occurs, or an operation is completed.

Event Source


A source is an object that generates an event. This occurs when the internal state of that object changes in some way. Sources may generate more than one type of event. A source must register listeners in order for the listeners to receive notifications about a specific type of event. Each type of event has its own registration method. public void addTypeListener(TypeListener el) Type is the name of the event and el is a reference to the event listener. The method that registers a keyboard event listener is called addKeyListener(). The method that registers a mouse motion listener is called addMouseMotionListener().
When an event occurs, all registered listeners are notified and receive a copy of the event object know as multicasting the event In all cases, notifications are sent only to listeners that register to receive them. Some sources may allow only one listener to register. General Form: public void addTypeListener(TypeListener el) throws java.util.TooManyListenersException Type is the name of the event and el is a reference to the event listener. When such an event occurs, the registered listener is notified. This is known as unicasting the event. A source must also provide a method that allows a listener to unregister an interest in a specific type of event. The general form of such a method is this: public void removeTypeListener(TypeListener el)

Event Listener


A listener is an object that is notified when an event occurs. Listener has two major requirements. It must have been registered with one or more sources to receive notifications about specific types of events. It must implement methods to receive and process these notifications. The methods that receive and process events are defined in a set of interfaces found in java.awt.event. For example, the MouseMotionListener interface defines two methods to receive notifications when the mouse is dragged or moved. Any object may receive and process one or both of these events if it provides an implementation of this interface.



Related Tutorials/Questions & Answers:
Java event-delegation model
Java event-delegation model  What is the advantage of the event-delegation model over the earlier eventinheritance model
Java event delegation model
Java event delegation model  What is the highest-level event class of the event-delegation model
Advertisements
delegation event model
delegation event model  What is delegation event model?   delegation event model In the event-delegation model, specific objects...-listener interfaces. Advantages of event-delegation model: 1)It enables
Java single threaded model
Java single threaded model  How single threaded model works after implementation in class, basically architecture point of view
Java event handling
Java event handling  What event results from the clicking of a button
Java event-listener
Java event-listener  What is the relationship between an event-listener interface and an event-adapter class
Java event handling
Java event handling  Which java.util classes and interfaces support event handling
Java event handling
Java event handling  What is the purpose of the enableEvents() method
Java AWT event hierarchy
Java AWT event hierarchy  What class is the top of the AWT event hierarchy?  The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy
Need an Example of calendar event in java
Need an Example of calendar event in java  can somebody give me an example of calendar event of java
mouse event - Java Beginners
=getContentPane(); setLayout(new FlowLayout()); setTitle("Mouse Event... Event"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(btnClose
Event handling - Java Beginners
Event handling  Hi, This is a similar kind of question i had asked before, with a little difference. Two JCombobox and a JtextField. When I select an Item from the first Combo(i.e.,Select,First,Second or Third),the set
Event Handling - Java Beginners
Event Handling  import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Calculator extends JFrame { JLabel lblNumber=new JLabel("Number"); JLabel lblSquareRoot=new JLabel("Square Root
Java window state event
Java window state event  Two java windows, one on top of another... Window at the back is deactivated when the other is on the top. Can iconify when there is only one window using win+d key. In windows, press win+d, window
java swing button click event
java swing button click event  java swing button click event   public void doClick()   Java Swing Tutorials
need model coding in java - Java Beginners
need model coding in java  i want model a program for an algorithm in java which is it has some transactions T1=ABCE T2=CDE T3=DE T4=CDEG T5=BG T6=AE T7=BCG T8=C T9=A now compare T9=A and T6=AE
Java Model View Controller (MVC) Design Pattern
; margin-left: 400px; } .style4 { margin-left: 160px; } Java MVC ( Model View Controller ) Design Pattern Model View controller is a classical design... into three parts. 1. Model- This component manages the information and notify
Event Handling In Java
Event Handling In Java In this section you will learn about how to handle.... In Java event handling may comprised the following four classes : Event Sources : Sources for generating an event may be the components. In Java
is having any method same behavior of Single thread model in java?
is having any method same behavior of Single thread model in java?  is having any method same behavior of Single thread model in java
is having any method same behavior of Single thread model in java?
is having any method same behavior of Single thread model in java?  is having any method same behavior of Single thread model in java
is having any method same behavior of Single thread model in java?
is having any method same behavior of Single thread model in java?  is having any method same behavior of Single thread model in java
is having any method same behavior of Single thread model in java?
is having any method same behavior of Single thread model in java?  is having any method same behavior of Single thread model in java
event-driven programming paradigm of Java. - Java Beginners
event-driven programming paradigm of Java.  Design a scientific calculator using event-driven programming paradigm of Java.  Hi Friend, Please visit the following link: http://www.roseindia.net/tutorial/java/swing
JComboBox Event Handling - Java Beginners
JComboBox Event Handling  Hi, I have problem with event handling here.There are Two JComboBox and a JTextField.When I select an item in first combo(Select,First,Second in the below program) the items in the second combo change
What are events? Explain how Event handling in Java?
What are events? Explain how Event handling in Java?  What are events? Explain how Event handling in Java?   Hi, The Events..., and introduces us to AWT event handling. For Details about Event Handling in Java
Java Swing Key Event
Java Swing Key Event In this tutorial, you will learn how to perform key event in java swing. Here is an example that change the case of characters to uppercase as the user enters any character. The given code accepts the string from
Handling Key Press Event in Java
Handling Key Press Event in Java   ... the handling key press event in java. Key Press is the event is generated when you press any key to the specific component. This event is performed by the KeyListener
Model in struts
Model in struts  what is a model in struts
Introduction to POJO (Plain Old Java Object) Programming Model
Introduction to POJO (Plain Old Java Object) Programming Model... features of added by Sun Microsystems in EJB 3.0 is POJO (Plain Old Java Object). It is a Java object that doesn't extend or implement some specialized
Return Value From Event - Java Beginners
Return Value From Event  I would like to call a method that returns a value after an event has occurred and the value is determined by the event or listener. eg: public int mymethod() { static int value=0; KeyAdapter
Event Listeners
Event Listeners  I want to learn the Event Listeners in Java. Any... is the good tutorial and example of Event Listeners in Java. Please check the tutorial Java - Event Listeners Example in Java Applet. Thanks
 

 

 

DMCA.com