Event Types 

  • In the previous section, we showed how to subclass a button and handle an action event. Buttons post action events when they are pressed and the event ID for an action event is ACTION_EVENT. So, in our handleEvent() routine, we checked for an event id of ACTION_EVENT to determine if the event passed to the handleEvent() routine was an action event: 
  • if (event.id == Event.ACTION_EVENT)
        System.out.println("I got an action: " + event);
  • However, action events are only one type of event. There are many more. The following table outlines some of the more important 
Event ID Called When
ACTION_EVENT An action occurs.
GOT_FOCUS A component gained focus.
KEY_PRESS A key is pressed.
KEY_RELEASE A key is released.
LIST_DESELECT An item is deselected.
LIST_SELECT An item is selected.
LOST_FOCUS A component loses focus.
MOUSE_DOWN A mouse button is pressed.
MOUSE_DRAG The mouse is moved while it is pressed.
MOUSE_ENTER The mouse enters a component.
MOUSE_EXIT The mouse exists a component.
MOUSE_MOVE The mouse is moved.
MOUSE_UP The mouse button is released.
SCROLL_ABSOLUTE The thumb in a scrolling component is moved
SCROLL_LINE_DOWN A line down in a scrolling component is activated.
SCROLL_LINE_UP A line up in a scrolling component is activated.
SCROLL_PAGE_DOWN A page down in a scrolling component is activated.
SCROLL_PAGE_UP A page up in a scrolling component is activated.
WINDOW_DEICONIFY A window is de-iconified.
WINDOW_DESTROY A window is destroyed (closed).
WINDOW_EXPOSE A window is exposed (displayed).
WINDOW_ICONIFY A window is iconified.
WINDOW_MOVED A window is moved.

Additional Resources:

JDK 1.0 Event Handling
Table of Contents
Other Methods for Handling Events


Graphics & Media Lab. >> Библиотека | Курсы | Графикон

Hosted by Graphics & Media Lab
http://graphics.cs.msu.su
lab_logo
mailto: Laboratory