本文整理汇总了Java中java.awt.event.AWTEventListenerProxy类的典型用法代码示例。如果您正苦于以下问题:Java AWTEventListenerProxy类的具体用法?Java AWTEventListenerProxy怎么用?Java AWTEventListenerProxy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AWTEventListenerProxy类属于java.awt.event包,在下文中一共展示了AWTEventListenerProxy类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isLayerEventControllerAdded
import java.awt.event.AWTEventListenerProxy; //导入依赖的package包/类
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;
}
示例2: layerEventControllerMaskEquals
import java.awt.event.AWTEventListenerProxy; //导入依赖的package包/类
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;
}
示例3: removeAWTEventListener
import java.awt.event.AWTEventListenerProxy; //导入依赖的package包/类
/**
* Removes an AWT event listener from this toolkit. This listener is no
* longer informed of any event types it was registered in.
*
* If a security manager is installed, it is asked first if an
* <code>AWTPermission("listenToAllAWTEvents")</code> is allowed.
* This may result in a <code>SecurityException</code> beeing thrown.
*
* It is not recommended to use this kind of notification for normal
* applications. It is intended solely for the purpose of debugging and to
* support special facilities.
*
* @param listener the listener to remove
*
* @throws SecurityException if there is a <code>SecurityManager</code> that
* doesn't grant
* <code>AWTPermission("listenToAllAWTEvents")</code>
*
* @since 1.2
*
* @see #addAWTEventListener(AWTEventListener, long)
* @see #getAWTEventListeners()
* @see #getAWTEventListeners(long)
*/
public void removeAWTEventListener(AWTEventListener listener)
{
// First we must check the security permissions.
SecurityManager s = System.getSecurityManager();
if (s != null)
s.checkPermission(new AWTPermission("listenToAllAWTEvents"));
// Find the index of the listener.
int index = -1;
for (int i = 0; i < awtEventListeners.length; ++i)
{
AWTEventListenerProxy proxy = awtEventListeners[i];
if (proxy.getListener() == listener)
{
index = i;
break;
}
}
// Copy over the arrays and leave out the removed element.
if (index != -1)
{
AWTEventListenerProxy[] newArray =
new AWTEventListenerProxy[awtEventListeners.length - 1];
if (index > 0)
System.arraycopy(awtEventListeners, 0, newArray, 0, index);
if (index < awtEventListeners.length - 1)
System.arraycopy(awtEventListeners, index + 1, newArray, index,
awtEventListeners.length - index - 1);
awtEventListeners = newArray;
}
}
示例4: globalDispatchEvent
import java.awt.event.AWTEventListenerProxy; //导入依赖的package包/类
/**
* Dispatches events to listeners registered to this Toolkit. This is called
* by {@link Component#dispatchEventImpl(AWTEvent)} in order to dispatch
* events globally.
*
* @param ev the event to dispatch
*/
void globalDispatchEvent(AWTEvent ev)
{
// We do not use the accessor methods here because they create new
// arrays each time. We must be very efficient, so we access this directly.
for (int i = 0; i < awtEventListeners.length; ++i)
{
AWTEventListenerProxy proxy = awtEventListeners[i];
if ((proxy.getEventMask() & AWTEvent.eventIdToMask(ev.getID())) != 0)
proxy.eventDispatched(ev);
}
}
示例5: removeAWTEventListener
import java.awt.event.AWTEventListenerProxy; //导入依赖的package包/类
void removeAWTEventListener(AWTEventListener listener) {
if (listener != null) {
for (AWTEventListenerProxy proxy : listeners.getUserListeners()) {
if (listener == proxy.getListener()) {
listeners.removeUserListener(proxy);
return;
}
}
}
}
示例6: getAWTEventListeners
import java.awt.event.AWTEventListenerProxy; //导入依赖的package包/类
AWTEventListener[] getAWTEventListeners() {
HashSet<EventListener> listenersSet = new HashSet<EventListener>();
for (AWTEventListenerProxy proxy : listeners.getUserListeners()) {
listenersSet.add(proxy.getListener());
}
return listenersSet.toArray(new AWTEventListener[listenersSet.size()]);
}
示例7: dispatchAWTEvent
import java.awt.event.AWTEventListenerProxy; //导入依赖的package包/类
void dispatchAWTEvent(AWTEvent event) {
AWTEvent.EventDescriptor descriptor = eventTypeLookup.getEventDescriptor(event);
if (descriptor == null) {
return;
}
for (AWTEventListenerProxy proxy : listeners.getUserListeners()) {
if ((proxy.getEventMask() & descriptor.eventMask) != 0) {
proxy.eventDispatched(event);
}
}
}