本文整理汇总了Java中java.awt.event.AWTEventListenerProxy.getListener方法的典型用法代码示例。如果您正苦于以下问题:Java AWTEventListenerProxy.getListener方法的具体用法?Java AWTEventListenerProxy.getListener怎么用?Java AWTEventListenerProxy.getListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.event.AWTEventListenerProxy
的用法示例。
在下文中一共展示了AWTEventListenerProxy.getListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
示例2: 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;
}
}
}
}