/**
* 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;
}
}
Toolkit.java 文件源码
java
阅读 39
收藏 0
点赞 0
评论 0
项目:JamVM-PH
作者:
评论列表
文章目录