Event Handling

Mouse Double Click Example Java

The code explains how to handle double clicks of mouse key. You even can handle triple clicks also, if required. Example on Mouse Double Click Example import java.awt.*; import java.awt.event.*; public class Demo extends Frame { Button btn; public Demo() { setLayout(new FlowLayout()); btn = new Button(“OK”); btn.addMouseListener(new MyListener()); add(btn); setSize(300,300); setVisible(true); } public static …

Mouse Double Click Example Java Read More »

Mouse Right Click Example Java

This Java code on Mouse Right Click Example explains how to handle the right clicks of mouse key. Mouse Right Click Example import java.awt.*; import java.awt.event.*; public class Demo extends Frame { Button btn; public Demo() { setLayout(new FlowLayout()); btn = new Button(“OK”); btn.addMouseListener(new MyListener()); add(btn); setSize(300,300); setVisible(true); } public static void main(String args[]) { …

Mouse Right Click Example Java Read More »

Java AWT Adapters

Java AWT Adapters are abstract classes from java.awt.event package introduced with JDK 1.1. Adapter classes make event handling simple and easy. Adapters usage replaces the listeners; adapters make event handling easy to the programmer. Every listener that includes more than one abstract method has got a corresponding adapter class. The advantage of adapter is that …

Java AWT Adapters Read More »

Java AWT Listeners

Java AWT Listeners are a group of interfaces from java.awt.event package. Listeners are capable to handle the events generated by the components like button, choice, frame etc. These listeners are implemented to the class which requires handling of events. public class ButtonDemo1 extends Frame implements ActionListener The class ButtonDemo1 implements ActionListener as ButtonDemo1 includes some …

Java AWT Listeners Read More »