AWT Events in Java

AWT Events in Java,

MouseListener and MouseMotionListener Example

We did two separate programs on mouse event handling with MouseListener and MouseMotionListener. Now let us have an example implementing both mouse listener interfaces. It is very simple, but required to override 5 abstract methods of MouseListener and 2 abstract methods of MouseMotionListener. To make the program simple, just I am changing the background color …

MouseListener and MouseMotionListener Example Read More »

Handling MouseEvent with MouseMotionListener Example

There is no MouseMotionEvent in java. The same MouseEvent used in MouseListener is used in MouseMotionListener also. All the abstract methods of both the interfaces takes MouseEvent as parameter. Two types of events can be generated with by mouse button when the mouse is in motion. One is just moving the mouse on a component …

Handling MouseEvent with MouseMotionListener Example Read More »

Handling MouseEvent with MouseListener Example

MouseEvent is handled by MouseListener overriding 5 abstract methods. Example given with Screenshot in Simple terms. Java events are of two types – a) generated by frame, button etc. (AWT components) known as semantic events and b) generated by mouse, keyboard (Hardware components) known as low-level events. When you click a mouse, the mouse generates …

Handling MouseEvent with MouseListener Example Read More »

Java Tutorial Key Event, Keyboard Input and KeyListener

Keyboard generate KeyEvent and handled by KeyListener overriding 3 abstract methods. Example given with Screenshot where key typed is displayed in TextField. Every component either software (like button) or hardware (like keyboard or mouse) when interacted by the user generates an event. The events can be categorized into two – Semantic and Low-level. Semantic events …

Java Tutorial Key Event, Keyboard Input and KeyListener Read More »

MouseListener MouseAdapter Applet

We know in Java, every listener interface that has got more than one abstract method comes with a corresponding adapter class. Usage of adapters classes in Java programming makes coding simple. Two programs (one as applet and the other as frame) are given to handle the events of mouse with MouseListener and MouseAdapter. To understand …

MouseListener MouseAdapter Applet Read More »

MouseListener Java Example

The events of Java AWT can be divided into two broad categories – Semantic events and Low-level events. Semantic events are generated by software (GUI) components like frame, button etc and low-level events are generated by hardware components like mouse, keyboard etc. You have seen so far the semantic events and their handling. Now let …

MouseListener Java Example Read More »

KeyListener Example

After seeing the low-level events handling with MouseListener and MouseMotionListener, let us go to the actions of keyboard. Keyboard actions are handled by KeyListener. Keyboard generates KeyEvent. Three types of actions can be done with keyboard – by pressing the key, by releasing the key and typing the key. These actions are represented by three …

KeyListener Example Read More »