EVENT LISTENER INTERFACE Java Help

EVENT LISTENER INTERFACE

As explained, the delegation event model has two parts: sources and listeners. Listeners are created by implementing one or more of the interfaces defined by the java awt event package. When an event occurs, the event source invokes the appropriate method defined by the listener and provides an event object as its argument. Table 20-3 lists commonly.

used listener interfaces and provides a brief description of the methods that they define. The following sections examine the specific methods that are contained in each interface .

The Action Listener Interface

This interface defines the action Performed( ) method that’ is invoked when an action  event occurs. Its genera) form is shown here:
void action Performed (Action Event ae).

The Adjustment Listener Interface

This interface defines the adjustment Value Changed( ) method that is invoked then  an adjustment event occurs. Its general form is shown here.

The Component Listener Interface

The interface defines lour methods that are invoked when a component is resided, moved, shown, .or hidden. Their general’ forms are shown here:

void component Re sized (Component Event ce)
void component Moved (Component Event ce)
void component Shown (Component Event ce)
void component Forbidden Component Event ce)

The Container Listener Interface

This interface contains two methods. When a component is added to a container component Added( )..is.invoked. When a component is removed Rom a container component removed ) is invoked. Their general forms are shown here:

The Liechtensteiner Interface

This interface defines two methods. When a component obtains keyboard focus, focus Gained( ) is invoked. When a component loses keyboard focus, focus Lost( ) is called. Their general forms are shown here:

The Item Listener Interface
This interface defines the item State Changed( ) method that is invoked when the state
of an item changes. Its genera

The Key Listener Interface
This interface defines three methods. The key Pressed( ) and key released ) methods
are invoked when a key is pressed and released, respectively. The key Typed( ) method  is invoked when a character has been entered.For example, if a user presses and releases the A key, three events are generated in sequence: key pressed, typed, and released. If a user presses and releases the HOME key, two key events are generated in sequence: key pressed and released The general forms of these methods are shown here.

JavaHelpOnline.com

  • Feel free to send us an inquiry, we will reply back in hours.
 

Verification

Posted on September 17, 2014 in Event Handling

Share the Story

About the Author

Back to Top
Share This