Search in sources :

Example 11 with AWTEventListener

use of java.awt.event.AWTEventListener in project jdk8u_jdk by JetBrains.

the class TestErrorException method init.

public void init() {
    robot = Util.createRobot();
    kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {

        public void eventDispatched(AWTEvent event) {
            System.out.println("--> " + event);
        }
    }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK);
}
Also used : AWTEventListener(java.awt.event.AWTEventListener) AWTEvent(java.awt.AWTEvent)

Example 12 with AWTEventListener

use of java.awt.event.AWTEventListener in project jdk8u_jdk by JetBrains.

the class bug6872503 method isLayerEventControllerAdded.

static boolean isLayerEventControllerAdded() {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    AWTEventListener layerEventController = null;
    for (AWTEventListener listener : toolkit.getAWTEventListeners()) {
        if (listener instanceof AWTEventListenerProxy) {
            listener = ((AWTEventListenerProxy) listener).getListener();
        }
        if ("LayerEventController".equals(listener.getClass().getSimpleName())) {
            if (layerEventController != null) {
                throw new RuntimeException("Duplicated LayerEventController");
            }
            layerEventController = listener;
        }
    }
    boolean ret = layerEventController != null;
    if (ret) {
        System.out.println("LayerEventController found");
    } else {
        System.out.println("No LayerEventController");
    }
    return ret;
}
Also used : AWTEventListener(java.awt.event.AWTEventListener) AWTEventListenerProxy(java.awt.event.AWTEventListenerProxy)

Example 13 with AWTEventListener

use of java.awt.event.AWTEventListener in project JMRI by JMRI.

the class Apps3 method splash.

protected static void splash(boolean show, boolean debug) {
    if (debugListener == null && debug) {
        // set a global listener for debug options
        debugFired = false;
        debugListener = new AWTEventListener() {

            @Override
            @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "debugmsg write is semi-global")
            public void eventDispatched(AWTEvent e) {
                if (!debugFired) {
                    /*We set the debugmsg flag on the first instance of the user pressing any button
                         and the if the debugFired hasn't been set, this allows us to ensure that we don't
                         miss the user pressing F8, while we are checking*/
                    debugmsg = true;
                    if (e.getID() == KeyEvent.KEY_PRESSED && e instanceof KeyEvent && ((KeyEvent) e).getKeyCode() == 119) {
                        startupDebug();
                    } else {
                        debugmsg = false;
                    }
                }
            }
        };
        Toolkit.getDefaultToolkit().addAWTEventListener(debugListener, AWTEvent.KEY_EVENT_MASK);
    }
    // bring up splash window for startup
    if (sp == null) {
        sp = new SplashWindow((debug) ? splashDebugMsg() : null);
    }
    sp.setVisible(show);
    if (!show) {
        sp.dispose();
        Toolkit.getDefaultToolkit().removeAWTEventListener(debugListener);
        debugListener = null;
        sp = null;
    }
}
Also used : KeyEvent(java.awt.event.KeyEvent) AWTEventListener(java.awt.event.AWTEventListener) SplashWindow(apps.SplashWindow) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) AWTEvent(java.awt.AWTEvent)

Aggregations

AWTEventListener (java.awt.event.AWTEventListener)13 AWTEvent (java.awt.AWTEvent)4 KeyEvent (java.awt.event.KeyEvent)3 AWTEventListenerProxy (java.awt.event.AWTEventListenerProxy)2 JButton (javax.swing.JButton)2 JTextComponent (javax.swing.text.JTextComponent)2 SplashWindow (apps.SplashWindow)1 DnDAware (com.intellij.ide.dnd.DnDAware)1 DarculaLaf (com.intellij.ide.ui.laf.darcula.DarculaLaf)1 Disposable (com.intellij.openapi.Disposable)1 Project (com.intellij.openapi.project.Project)1 AsyncResult (com.intellij.openapi.util.AsyncResult)1 Ref (com.intellij.openapi.util.Ref)1 IdeFocusManager (com.intellij.openapi.wm.IdeFocusManager)1 IdeGlassPane (com.intellij.openapi.wm.IdeGlassPane)1 ToolWindow (com.intellij.openapi.wm.ToolWindow)1 FocusManagerImpl (com.intellij.openapi.wm.impl.FocusManagerImpl)1 FocusRequestInfo (com.intellij.openapi.wm.impl.FocusRequestInfo)1 ShowUIDefaultsAction (com.intellij.ui.ShowUIDefaultsAction)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1