answersLogoWhite

0

Event HandlingWhen the user acts on a Component -- clicking it or pressing the Return key, for example -- an Event object is created. The AWT event-handling system passes the Event up the Component hierarchy, giving each Component a chance to react to the event before the platform-dependent code that implements the Component fully processes it.

Each Component's event handler can react to an event in any of the following ways:

  • By ignoring the event and allowing it to be passed up the Component hierarchy. This is what the default Component implementation does. For example, since the TextField class and its TextComponent superclass implement no event handlers, TextFields get the default Component implementation. So when a TextField receives an Event, it ignores it and allows its container to handle it.
  • By modifying the Event instance before it goes further up the hierarchy. For example, a TextField subclass that displays all letters in uppercase might react to the keypress of a lowercase letter by changing the Event to contain the uppercase version of the letter.
  • By reacting in some other way to the event. For example, a TextField subclass (or a TextField's container) could react to a Return keypress by calling a method that processes the text field's contents.
  • By intercepting the event, stopping it from being processed further. For example, if an invalid character is entered in a text field, an event handler could simply stop the resulting Event from propagating upward. As a result, the platform-dependent implementation of the text field would never see the event.

From a Component's view, the AWT event-handling system is more like an event-filtering system. Platform-dependent code generates an event, but Components get a chance to modify, react to, or intercept the event before the platform-dependent code fully processes the event.

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

When two or more objects are added as listeners for the same event which listener is invoked first to handle the event?

First to arrive at the event.


Event Meeting Planning?

If you are responsible for your company's event meeting planning duties, you may be better off hiring an outside party or event specialist, that will handle the small details for you.


5 Star Event Services?

When you have a special event that you know has to go off without a single hitch, consider hiring 5 star event services. Let someone else handle all the details.


Careers Event Planning?

Events for your office or company are so much easier and more enjoyable when you hire careers event planning specialists. Let the professionals handle it.


What are the steps used in delegation event model?

The delegation event model involves three main steps: first, an event is triggered by a user interaction, such as a click or keypress. Second, the event bubbles up through the DOM hierarchy, allowing parent elements to listen for and handle the event. Finally, the appropriate event handler is executed, allowing the desired action to take place in response to the event. This model promotes efficiency by reducing the number of event listeners needed on individual elements.


What is the explanation for the swing delegation event model?

The Swing delegation event model in Java is based on the principle of event listeners and event sources. In this model, components (like buttons or text fields) act as event sources that generate events when user interactions occur. These events are then processed by registered listeners—objects that implement specific interfaces to handle particular types of events. This decouples the event generation from event handling, allowing for flexible and modular code design, as multiple listeners can respond to the same event source.


How can you handle conversation monopolizers during a networking event?

Yes, you should act professionally with these things all the time. But you should tell them upfront that it has limits too.


Outdoor Umbrella Table for Entertaining?

The largest sized table that is available for an outdoor umbrella can handle up to ten chairs. It would be great for a large event.


Difference between fault tree analysis and event tree analysis?

Difference between fault tree and event tree: 1) Fault trees lay out relationships among event whereas event trees lay out sequences of events linked by conditional probabilities. 2) Event trees can handle better notions of continuity (logical, temporal, and physical), whereas fault trees are most powerful in identifying and simplifying failure scenarios.


How should you name an event handler method in c?

In C, event handler methods should be named clearly and descriptively to reflect their purpose and the event they handle. A common convention is to use a prefix indicating the event type, followed by a description of the action or the object involved, such as onButtonClick or handleMouseEvent. Using camelCase or underscores for readability is also recommended. Consistency in naming across your codebase enhances maintainability and clarity.


What is an event counter?

An event counter is a variable that starts off set to zero and is incremented at a certain point in code which is passed when something (the event) is occurring. For example, if you want an event counter to determine how many times the user responds to the question "what was the student's grade" with the answer "100", then within the existing loop to handle data entry, you could simply add something along the lines of (if grade equals to 100 then event_counter = event_counter + 1) and there you have an event counter.


What do you mean by event in dotnet?

An "event" in .Net is an implementation of the Observer design pattern. When you declare that one of your classes has an event, you declare the name of the event, and the arguments that the event will pass. Then, your other classes can "Observe" when this event happens, and handle the event when it is "Fired".For example, the Button windows control has a "Click" event. You can then write code that watches for those clicks, and runs when it happens.An event in C# is a way for a class to provide notifications to clients of that class when some interesting thing happens to an object. The most familiar use for events is in graphical user interfaces; typically, the classes that represent controls in the interface have events that are notified when the user does something to the control (for example, click a button).