Search in sources :

Example 1 with AWTEventListenerProxy

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

the class bug6872503 method layerEventControllerMaskEquals.

static boolean layerEventControllerMaskEquals(long mask) {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    AWTEventListener layerEventController = null;
    for (AWTEventListener listener : toolkit.getAWTEventListeners(mask)) {
        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 with the correct mask found");
    } else {
        System.out.println("No LayerEventController with the correct mask");
    }
    return ret;
}
Also used : AWTEventListener(java.awt.event.AWTEventListener) AWTEventListenerProxy(java.awt.event.AWTEventListenerProxy)

Example 2 with AWTEventListenerProxy

use of java.awt.event.AWTEventListenerProxy 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)

Aggregations

AWTEventListener (java.awt.event.AWTEventListener)2 AWTEventListenerProxy (java.awt.event.AWTEventListenerProxy)2