當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。