当前位置: 首页>>代码示例>>Java>>正文


Java EventListener类代码示例

本文整理汇总了Java中java.util.EventListener的典型用法代码示例。如果您正苦于以下问题:Java EventListener类的具体用法?Java EventListener怎么用?Java EventListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EventListener类属于java.util包,在下文中一共展示了EventListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: AbstractPoolCache

import java.util.EventListener; //导入依赖的package包/类
/**
 * Constructor initializes the AbstractPoolCache properties.
 * 
 * @param eventListner The event listner for the database connections.
 * @param configs The ConfiguredDataSourceProperties object containing the configuration for the
 *        pool.
 * @throws PoolException
 */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "SC_START_IN_CTOR",
    justification = "the thread started is a cleanup thread and is not active until there is a timeout tx")
public AbstractPoolCache(EventListener eventListner, ConfiguredDataSourceProperties configs)
    throws PoolException {
  availableCache = new HashMap();
  activeCache = Collections.synchronizedMap(new LinkedHashMap());
  connEventListner = eventListner;
  expiredConns = Collections.synchronizedList(new ArrayList());
  MAX_LIMIT = configs.getMaxPoolSize();
  expirationTime = configs.getConnectionExpirationTime() * 1000;
  timeOut = configs.getConnectionTimeOut() * 1000;
  loginTimeOut = configs.getLoginTimeOut() * 1000;
  INIT_LIMIT = Math.min(configs.getInitialPoolSize(), MAX_LIMIT);
  configProps = configs;
  cleaner = this.new ConnectionCleanUpThread();
  ThreadGroup group = LoggingThreadGroup.createThreadGroup("Cleaner threads");
  th = new Thread(group, cleaner);
  th.setDaemon(true);
  th.start();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:29,代码来源:AbstractPoolCache.java

示例2: remove

import java.util.EventListener; //导入依赖的package包/类
/**
 * Removes the given listener from this listener list.
 * 
 * @param listener the listener to be removed. If null is passed it is ignored (nothing gets removed).
 */
public synchronized void remove(T listener) {
    if (listener == null)
        return;

    int idx = listenersList.indexOf(listener);
    if (idx == -1) {
        return;
    }
    
    EventListener [] arr = new EventListener[listenersList.getArray().length - 1];
    if (arr.length > 0) {
        System.arraycopy(listenersList.getArray(), 0, arr, 0, idx);
    }
    if (arr.length > idx) {
        System.arraycopy(listenersList.getArray(), idx + 1, arr, idx, listenersList.getArray().length - idx - 1);
    }
    
    listenersList = new ImmutableList<T>(arr);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ListenerList.java

示例3: writeObject

import java.util.EventListener; //导入依赖的package包/类
private void writeObject(ObjectOutputStream s) throws IOException {
Object[] lList = listenerList;
s.defaultWriteObject();

// Save the non-null event listeners:
for (int i = 0; i < lList.length; i+=2) {
    Class t = (Class)lList[i];
    EventListener l = (EventListener)lList[i+1];
    if ((l!=null) && (l instanceof Serializable)) {
	s.writeObject(t.getName());
	s.writeObject(l);
    }
}

s.writeObject(null);
   }
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:17,代码来源:EventListenerList.java

示例4: checkInstanceOf

import java.util.EventListener; //导入依赖的package包/类
private void checkInstanceOf() throws Exception {
    boolean is = testAppClass.isInstanceOf(APP_SRC_NAME);
    assertFalse(is);
    is = testAppClass.isInstanceOf(APP_CLASS_NAME);
    assertTrue("Instance of "+APP_CLASS_NAME, is);
    is = testAppClass.isInstanceOf(EventListener.class.getName());
    assertTrue("Instance of "+EventListener.class.getName(), is);

    is = multiImplClass.isInstanceOf("huuuhuuu");
    assertFalse(is);
    is = multiImplClass.isInstanceOf(APP_CLASS_NAME+"$MultiImpl");
    assertTrue("Instance of "+APP_CLASS_NAME+"$MultiImpl", is);
    is = multiImplClass.isInstanceOf(Runnable.class.getName());
    assertTrue("Instance of "+Runnable.class.getName(), is);
    is = multiImplClass.isInstanceOf(APP_CLASS_NAME+"$SuperImpl");
    assertTrue("Instance of "+APP_CLASS_NAME+"$SuperImpl", is);
    is = multiImplClass.isInstanceOf(APP_CLASS_NAME+"$Intrfc4");
    assertTrue("Instance of "+APP_CLASS_NAME+"$Intrfc4", is);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:JPDAClassTypeTest.java

示例5: add

import java.util.EventListener; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T extends EventListener> void add(Class<T> type, T listener)
{
	try
	{
		((ArrayList<T>)listenerMap.get(type)).add(listener);
		
	}catch(Throwable e)
	{
		e.printStackTrace();
		
		CrashReport report =
			CrashReport.makeCrashReport(e, "Adding Wurst event listener");
		CrashReportCategory category =
			report.makeCategory("Affected listener");
		category.setDetail("Listener type", () -> type.getName());
		category.setDetail("Listener class",
			() -> listener.getClass().getName());
		
		throw new ReportedException(report);
	}
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:23,代码来源:EventManager.java

示例6: addListener

import java.util.EventListener; //导入依赖的package包/类
/**
 * Adds an event listener to the Panel.
 *
 * @param eventListener
 *        The event listener.
 *
 * @throws IllegalArgumentException
 *        If the event listener isn't supported by this function.
 */
public void addListener(final EventListener eventListener) {
    if (eventListener instanceof KeyListener) {
        this.addKeyListener((KeyListener) eventListener);
        return;
    }

    if (eventListener instanceof MouseListener) {
        this.addMouseListener((MouseListener) eventListener);
        return;
    }

    if (eventListener instanceof MouseMotionListener) {
        this.addMouseMotionListener((MouseMotionListener) eventListener);
        return;
    }

    throw new IllegalArgumentException("The " + eventListener.getClass().getSimpleName() + " is not supported.");
}
 
开发者ID:Valkryst,项目名称:VTerminal,代码行数:28,代码来源:Panel.java

示例7: addListener

import java.util.EventListener; //导入依赖的package包/类
/**
 * Add a listener to be notified when notifyChanged is called.
 * The listener must not be null. AcceptsListener must return
 * true for the listener.  Attempts to concurrently
 * register the identical listener more than once will be
 * silently ignored.
 */
public void addListener(EventListener l) {
    if (l == null) {
        throw new NullPointerException();
    }

    if (acceptsListener(l)) {
        synchronized (notifyLock) {
            if (listeners == null) {
                listeners = new ArrayList<EventListener>();
            } else {
                // identity equality check
                for (EventListener ll : listeners) {
                    if (ll == l) {
                        return;
                    }
                }
            }

            listeners.add(l);
        }
    } else {
        throw new IllegalStateException("Listener invalid for this notifier.");
    }
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:32,代码来源:ICUNotifier.java

示例8: removeListener

import java.util.EventListener; //导入依赖的package包/类
/**
 * Stop notifying this listener.  The listener must
 * not be null.  Attemps to remove a listener that is
 * not registered will be silently ignored.
 */
public void removeListener(EventListener l) {
    if (l == null) {
        throw new NullPointerException();
    }
    synchronized (notifyLock) {
        if (listeners != null) {
            // identity equality check
            Iterator<EventListener> iter = listeners.iterator();
            while (iter.hasNext()) {
                if (iter.next() == l) {
                    iter.remove();
                    if (listeners.size() == 0) {
                        listeners = null;
                    }
                    return;
                }
            }
        }
    }
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:26,代码来源:ICUNotifier.java

示例9: populateListenerArray

import java.util.EventListener; //导入依赖的package包/类
private static int populateListenerArray(EventListener[] a, EventListener l, int index) {
    if (l instanceof AWTEventMulticaster) {
        AWTEventMulticaster mc = (AWTEventMulticaster)l;
        int lhs = populateListenerArray(a, mc.a, index);
        return populateListenerArray(a, mc.b, lhs);
    }
    else if (a.getClass().getComponentType().isInstance(l)) {
        a[index] = l;
        return index + 1;
    }
    // Skip nulls, instances of wrong class
    else {
        return index;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:AWTEventMulticaster.java

示例10: getListeners

import java.util.EventListener; //导入依赖的package包/类
private <T extends EventListener> List<Object> getListeners(@Nullable String target, Class<T> clazz)
{
	List<Object> listenerList = new ArrayList<Object>();
	for( SectionTree tree : trees )
	{
		listenerList.addAll(tree.getListeners(target, clazz));
	}
	return listenerList;
}
 
开发者ID:equella,项目名称:Equella,代码行数:10,代码来源:DefaultSectionInfo.java

示例11: fireAtomicLock

import java.util.EventListener; //导入依赖的package包/类
private void fireAtomicLock(AtomicLockEvent evt) {
    EventListener[] listeners = listenerList.getListeners(org.netbeans.api.editor.document.AtomicLockListener.class);
    int cnt = listeners.length;
    for (int i = 0; i < cnt; i++) {
        ((org.netbeans.api.editor.document.AtomicLockListener)listeners[i]).atomicLock(evt);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:BaseDocument.java

示例12: fireAtomicUnlock

import java.util.EventListener; //导入依赖的package包/类
private void fireAtomicUnlock(AtomicLockEvent evt) {
    EventListener[] listeners = listenerList.getListeners(org.netbeans.api.editor.document.AtomicLockListener.class);
    int cnt = listeners.length;
    for (int i = 0; i < cnt; i++) {
        ((org.netbeans.api.editor.document.AtomicLockListener)listeners[i]).atomicUnlock(evt);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:BaseDocument.java

示例13: WeakListener

import java.util.EventListener; //导入依赖的package包/类
/**
 * @param listenerClass class/interface of the listener
 * @param l listener to delegate to, <code>l</code> must be an instance of
 * listenerClass
 */
protected WeakListener(Class listenerClass, java.util.EventListener l) {
    this.listenerClass = listenerClass;
    ref = new ListenerReference(l, this);

    if (!listenerClass.isAssignableFrom(l.getClass())) {
        throw new IllegalArgumentException(
            getClass().getName() + " constructor is calling WeakListner.<init> with illegal arguments"
        ); // NOI18N
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:WeakListener.java

示例14: removeUpdate

import java.util.EventListener; //导入依赖的package包/类
/**
 * Implementation of DocumentListener's method fires all the added
 * listeners according to their priority.
 */
public void removeUpdate(DocumentEvent evt) {
    logEvent(evt, "removeUpdate");
    // Fire the prioritized listeners
    EventListener[][] listenersArray = getListenersArray();
    // Attempt to fire to all listeners catching possible exception(s) and report first fired then
    RuntimeException runtimeException = null;
    for (int priority = listenersArray.length - 1; priority >= 0; priority--) {
        logPriority(priority);
        EventListener[] listeners = listenersArray[priority];
        for (int i = listeners.length - 1; i >= 0; i--) {
            DocumentListener l = (DocumentListener) listeners[i];
            logListener(l);
            try {
                l.removeUpdate(evt);
            } catch (RuntimeException ex) {
                if (runtimeException == null) { // Only record first thrown
                    runtimeException = ex;
                }
            }
        }
    }
    if (runtimeException != null) {
        throw runtimeException; // Re-throw remembered exception
    }
    logEventEnd("removeUpdate");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:PriorityDocumentListenerList.java

示例15: addListener

import java.util.EventListener; //导入依赖的package包/类
@Override
public void addListener(final String className) {
    try {
        Class<? extends EventListener> clazz = (Class<? extends EventListener>) deploymentInfo.getClassLoader().loadClass(className);
        addListener(clazz);
    } catch (ClassNotFoundException e) {
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:ServletContextImpl.java


注:本文中的java.util.EventListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。