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);
}
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;
}
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;
}
}
Aggregations