What does listener do in java




















The EventListener function of the event handler to remove from the event target. A boolean value that specifies whether the EventListener to be removed is registered as a capturing listener or not. If this parameter is absent, a default value of false is assumed.

Given an event listener previously added by calling addEventListener , you may eventually come to a point at which you need to remove it.

Obviously, you need to specify the same type and listener parameters to removeEventListener. But what about the options or useCapture parameters?

Its value must match for removeEventListener to match, but the other values don't. The first call fails because the value of useCapture doesn't match. Top-level Listeners this are commonly used where there is only one source of an event. For example, if you are defining a subclass of JPanel to use for drawing with a mouse, an instance of this new class will typically also be the mouse event listener.

Similarly with a JPanel used for animation -- the panel itself may serve as the ActionListener for the Timer. Do not use "this" as a listener for buttons, menus, etc. Action and AbstractAction objects are action listeners. In some ways they are more powerful than other action listener strategies in that they can easily be used to enable or disable multiple controls.

An action object can be shared with many controls; eg, the same action is sometimes accomplished with a menu item and a button or toolbar tool. They encapsulate the name, description, enabled status, listener, and icon information. This is a good choice for large interfaces, and quite compatible with the MVC pattern see below. External Listeners - To implement the Model-View-Controller pattern, all listeners will effectively be in the Controller module.

There are a number of ways to split the controller actions from the View part of the interface. This class is defined in java. Previous Page. Next Page. Previous Page Print Page. Save Close. Dashboard Logout. ActionListener This interface is used for receiving the action events.



0コメント

  • 1000 / 1000