Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.*;
import java.awt.event.AWTEventListener;

public class Main {
    /**
     * Adds a global Keylistener which receive all KeyEvents which are sent.</br> Code
     * Example:</br> <code><pre>
     * AWTEventListener ael = new AWTEventListener() { 
     *    public void eventDispatched(AWTEvent e ) { 
     *       if(e.getID() == KeyEvent.KEY_PRESSED){
     *          doSomeThing(); //eg. keyPressed((KeyEvent) e);  
     *       }  
     *    }
     * };
     * </pre>
     *</code>
     * 
     * @param listener to add
     */
    public static void addGlobalKeyListener(AWTEventListener listener) {
        Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.KEY_EVENT_MASK);
    }
}