Example usage for java.awt Container addKeyListener

List of usage examples for java.awt Container addKeyListener

Introduction

In this page you can find the example usage for java.awt Container addKeyListener.

Prototype

public synchronized void addKeyListener(KeyListener l) 

Source Link

Document

Adds the specified key listener to receive key events from this component.

Usage

From source file:Main.java

public static void addKeyAdapterRecursively(final Container container, final KeyAdapter keyAdapter) {
    container.addKeyListener(keyAdapter);
    for (int i = 0; i < container.getComponentCount(); i++) {
        final Component child = container.getComponent(i);
        if (child instanceof Container) {
            addKeyAdapterRecursively((Container) child, keyAdapter);
        }/*from   w ww.j a va 2 s .co  m*/
        child.addKeyListener(keyAdapter);
    }
}