Introducing Untyped Listeners : SWT Event « SWT « Java Tutorial






  1. The untyped listener interface is represented by the Listener interface
  2. It contains one method: void handleEvent(Event event)

Event Members

MemberDescription
int buttonThe one-based index of the button that was clicked or released.
char characterThe character that was typed.
int countThe number of pending paint events.
Object dataApplication-specific data.
int detailA detail constant from the SWT class that contains details about the event.
Display displayThe display where the event occurred.
boolean doitA flag indicating whether to process this event. Not supported for all events.
int endThe end of the range of modified text.
GC gcThe graphics context associated with this event.
int heightThe height in pixels of the rectangle that needs painting.
Widget itemThe widget where the event occurred.
int keyCodeThe key code of the key that was typed.
int startThe beginning of the range of modified text.
int stateMaskThe mask describing the state of the modifier keys at the time of the event.
String textThe text to insert.
int timeThe event's time.
int typeThe type of the event. This is the field to switch on to handle the various event types.
Widget widgetThe widget that issued the event.
int widthThe width in pixels of the rectangle that needs painting.
int xEither the x offset of the rectangle that needs painting or the x coordinate of the mouse pointer at the time of the event, depending n the event.
int yEither the y offset of the rectangle that needs painting or the y coordinate of the mouse pointer at the time of the event, depending on the event.


To add an untyped listener to a widget, call addListener() on it.

void addListener(int eventType, Listener listener)

eventType contains one of the event type constants from the SWT class:

TypeDescription
SWT.ActivateTriggered when the widget becomes the active window
SWT.ArmTriggered when the widget is armed
SWT.CloseTriggered when the widget is closed
SWT.CollapseTriggered when a tree node is collapsed
SWT.DeactivateTriggered when the widget is no longer the active window
SWT.DefaultSelectionTriggered when the default selection occurs
SWT.DeiconifyTriggered when the widget is restored from being minimized
SWT.DisposeTriggered when the widget is disposed
SWT.DragDetectTriggered when the widget is dragged
SWT.ExpandTriggered when a tree node is expanded
SWT.FocusInTriggered when the widget gains focus
SWT.FocusOutTriggered when the widget loses focus
SWT.HardKeyDownTriggered when a special hardware key, such as on a Pocket PC device, is pressed
SWT.HardKeyUpTriggered when a special hardware key, such as on a Pocket PC device, is released
SWT.HelpTriggered when the user requests help
SWT.HideTriggered when the widget is hidden
SWT.IconifyTriggered when the widget is minimized
SWT.KeyDownTriggered when the user presses a key
SWT.KeyUpTriggered when the user releases a key
SWT.MenuDetectTriggered when a menu is selected
SWT.ModifyTriggered when the text of a widget is modified
SWT.MouseDoubleClickTriggered when the mouse is double-clicked
SWT.MouseDownTriggered when the mouse button is clicked
SWT.MouseEnterTriggered when the mouse pointer enters the widget
SWT.MouseExitTriggered when the mouse pointer exits the widget
SWT.MouseHoverTriggered when the mouse pointer hovers over the widget
SWT.MouseMoveTriggered when the mouse pointer moves through the widget
SWT.MouseUpTriggered when the mouse button is released
SWT.MoveTriggered when the widget is moved
SWT.NoneNull event
SWT.PaintTriggered when the widget is painted
SWT.ResizeTriggered when the widget is resized
SWT.SelectionTriggered when the widget is selected
SWT.ShowTriggered when the widget is shown
SWT.TraverseTriggered when the user tabs through the controls
SWT.VerifyTriggered when the text for the widget is about to change, allowing you to veto the change










17.89.SWT Event
17.89.1.Events
17.89.2.The Event ModelThe Event Model
17.89.3.The listener notification processThe listener notification process
17.89.4.SWT provides two kinds of event listening mechanism: typed and untyped.SWT provides two kinds of event listening mechanism: typed and untyped.
17.89.5.Untyped Events and Untyped Event ListenersUntyped Events and Untyped Event Listeners
17.89.6.Introducing Untyped Listeners
17.89.7.Get event typeGet event type
17.89.8.implements general Event Listenerimplements general Event Listener
17.89.9.Introducing Typed Listeners
17.89.10.Typed Listeners
17.89.11.SWT Message Keys and Values
17.89.12.Using SelectionListenerUsing SelectionListener
17.89.13.Add Resize listener to ShellAdd Resize listener to Shell
17.89.14.Add addPaintListener to CompositeAdd addPaintListener to Composite
17.89.15.Add default selection listener to ComboAdd default selection listener to Combo
17.89.16.Using HelpListenerUsing HelpListener
17.89.17.Demonstrate DisposeListener which is notified on the associated widget's disposal
17.89.18.Using ControlListenerUsing ControlListener
17.89.19.Using FocusListenerUsing FocusListener
17.89.20.Using VerifyListenerUsing VerifyListener
17.89.21.Using ModifyListenerUsing ModifyListener
17.89.22.Adding AccessibleListenerAdding AccessibleListener
17.89.23.Adding AccessibleControlListenerAdding AccessibleControlListener
17.89.24.Add and remove filter listenersAdd and remove filter listeners