Home arrow Java & J2EE arrow Page 3 - Event Handling In Java

Relax Back Event Handling In A Nut Shell - Java

In life, you encounter events that force you to suspend other activities and respond to them immediately. In Java, events represent all activity that goes on between the user and the application. Java's Abstract Windowing Toolkit (AWT) communicates these actions to the programs using events.

  1. Event Handling In Java
  2. Going Into Over Drive
  3. Relax Back Event Handling In A Nut Shell
  4. Event-Handling In Java
  5. Amazingly Simple Applets
  6. Naughty Examples For Those Little Mice
  7. A Quick Recap
By: Gayathri Gokul
Rating: starstarstarstarstar / 196
September 11, 2003

print this article


Semantic events are defined at a higher-level to encapsulate the semantics of user interface component’s model. Now let us see what are the various semantic event classes and what they generate:

• An ActionEvent object is generated when a component is activated

• An AdjustmentEvent Object is generated when scrollbars and other adjustment elements are used.

• A TextEvent object is generated when text of a component is modified.

• An ItemEvent is generated when an item from a list, a choice or checkbox is selected.

Low-Level Events is one that represents a low-level input or windows-system occurrence on a visual component on the screen. The various low-level event classes and what they generate are as follows:

• A ContainerEvent Object is generated when component are added or removed from container.

• A ComponentEvent object is generated when a component is resized, moved etc.

• A FocusEvent object is generated when component receives focus for input.

• A KeyEvent object is generated when key on keyboard is pressed, released etc.

• A WindowEvent object is generated when a window activity, like maximizing or close occurs.

• A MouseEvent object is generated when a mouse is used.

• A PaintEvent object is generated when component is painted.

Event Listeners: An object delegates the task of handling an event to an event listener. When an event occurs, an event object of the appropriate type (as illustrated below) is created. This object is passed to a Listener. A listener must implement the interface that has the method for event handling. A component can have multiple listeners, and a listener can be removed using removeActionListener () method. Next question in your mind must be what is an interface?. An Interface contains constant values and method declaration. The difference between classes and interface is that the methods in an interface are only declared and not implemented, that is, the methods do not have a body. What is the Need for interface? Are interfaces are used to define behavior protocols (standard behavior) that can be implemented by any class anywhere in the class hierarchy. The java.awt.event package contains definitions of all event classes and listener interface. The semantic listener interfaces define by AWT for the above mentioned semantic events are:

• ActionListener

• AjdustmentListener

• ItemListener

• TextListener

The low-level event listeners are as follows:

• ComponentListener

• ContainerListener

• FocusListener

• KeyListener

• MouseListener

• MouseMotionListener

• WindowsListener.

>>> More Java & J2EE Articles          >>> More By Gayathri Gokul

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates


Dev Shed Tutorial Topics: