类java.util.TooManyListenersException源码实例Demo

下面列出了怎么用java.util.TooManyListenersException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: blog-codes   文件: mxGraphHandler.java
/**
 * 
 */
protected void installDropTargetHandler()
{
	DropTarget dropTarget = graphComponent.getDropTarget();

	try
	{
		if (dropTarget != null)
		{
			dropTarget.addDropTargetListener(this);
			currentDropTarget = dropTarget;
		}
	}
	catch (TooManyListenersException e)
	{
		// should not happen... swing drop target is multicast
		log.log(Level.SEVERE, "Failed to install drop target handler", e);
	}
}
 
源代码2 项目: pega-tracerviewer   文件: TraceTabbedPane.java
public TraceTabbedPane(TracerViewerSetting tracerViewerSetting, RecentFileContainer recentFileContainer) {
    super();

    this.tracerViewerSetting = tracerViewerSetting;
    this.recentFileContainer = recentFileContainer;

    fileTabIndexMap = new LinkedHashMap<String, Integer>();

    setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);

    normalBorder = getBorder();

    try {
        DropTarget dt = new DropTarget();
        dt.addDropTargetListener(this);
        setDropTarget(dt);
    } catch (TooManyListenersException e) {
        LOG.error("Error adding drag drop listener", e);
    }
}
 
public void openSerial(String serialPortName, int speed) throws PortInUseException, IOException, UnsupportedCommOperationException, TooManyListenersException {
	
	CommPortIdentifier commPortIdentifier = findPort(serialPortName);
	
	// initalize serial port
	serialPort = (SerialPort) commPortIdentifier.open("Arduino", 2000);
	inputStream = serialPort.getInputStream();
	serialPort.addEventListener(this);

	// activate the DATA_AVAILABLE notifier
	serialPort.notifyOnDataAvailable(true);

	serialPort.setSerialPortParams(speed, SerialPort.DATABITS_8, 
			SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
	serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
}
 
源代码4 项目: netbeans   文件: ExplorerDragSupport.java
/** Activates or deactivates Drag support on asociated JTree
* component
* @param active true if the support should be active, false
* otherwise
*/
public void activate(boolean active) {
    if (this.active == active) {
        return;
    }

    this.active = active;

    DragGestureRecognizer dgr = getDefaultGestureRecognizer();
    if (dgr == null) {
        return;
    }

    if (active) {
        dgr.setSourceActions(getAllowedDragActions());

        try {
            dgr.removeDragGestureListener(this);
            dgr.addDragGestureListener(this);
        } catch (TooManyListenersException exc) {
            throw new IllegalStateException("Too many listeners for drag gesture."); // NOI18N
        }
    } else {
        dgr.removeDragGestureListener(this);
    }
}
 
源代码5 项目: darklaf   文件: DarkTabFrameUI.java
protected void installDnD() {
    tabFrame.setTransferHandler(TRANSFER_HANDLER);
    try {
        DropTarget dropTarget = tabFrame.getDropTarget();
        if (dropTarget != null) {
            dropTarget.addDropTargetListener(TRANSFER_HANDLER);
            dropTarget.setActive(tabFrame.isDndEnabled());
        }
    } catch (TooManyListenersException e) {
        e.printStackTrace();
    }
}
 
源代码6 项目: blog-codes   文件: EditorRuler.java
/**
 * Constructs a new ruler for the specified graph and orientation.
 * 
 * @param graph
 *            The graph to create the ruler for.
 * @param orientation
 *            The orientation to use for the ruler.
 */
public EditorRuler(mxGraphComponent graphComponent, int orientation)
{
	this.orientation = orientation;
	this.graphComponent = graphComponent;
	updateIncrementAndUnits();

	graphComponent.getGraph().getView().addListener(
			mxEvent.SCALE, repaintHandler);
	graphComponent.getGraph().getView().addListener(
			mxEvent.TRANSLATE, repaintHandler);
	graphComponent.getGraph().getView().addListener(
			mxEvent.SCALE_AND_TRANSLATE, repaintHandler);

	graphComponent.getGraphControl().addMouseMotionListener(this);

	DropTarget dropTarget = graphComponent.getDropTarget();

	try
	{
		if (dropTarget != null)
		{
			dropTarget.addDropTargetListener(this);
		}
	}
	catch (TooManyListenersException tmle)
	{
		// should not happen... swing drop target is multicast
	}

	setBorder(BorderFactory.createLineBorder(Color.black));
}
 
源代码7 项目: jdk1.8-source-analysis   文件: DropTarget.java
/**
 * Creates a new DropTarget given the <code>Component</code>
 * to associate itself with, an <code>int</code> representing
 * the default acceptable action(s) to
 * support, a <code>DropTargetListener</code>
 * to handle event processing, a <code>boolean</code> indicating
 * if the <code>DropTarget</code> is currently accepting drops, and
 * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c         The <code>Component</code> with which this <code>DropTarget</code> is associated
 * @param ops       The default acceptable actions for this <code>DropTarget</code>
 * @param dtl       The <code>DropTargetListener</code> for this <code>DropTarget</code>
 * @param act       Is the <code>DropTarget</code> accepting drops.
 * @param fm        The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE>
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 *            returns true
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public DropTarget(Component c, int ops, DropTargetListener dtl,
                  boolean act, FlavorMap fm)
    throws HeadlessException
{
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    component = c;

    setDefaultActions(ops);

    if (dtl != null) try {
        addDropTargetListener(dtl);
    } catch (TooManyListenersException tmle) {
        // do nothing!
    }

    if (c != null) {
        c.setDropTarget(this);
        setActive(act);
    }

    if (fm != null) {
        flavorMap = fm;
    } else {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }
}
 
源代码8 项目: openjdk-8-source   文件: DropTarget.java
/**
 * Adds a new <code>DropTargetListener</code> (UNICAST SOURCE).
 * <P>
 * @param dtl The new <code>DropTargetListener</code>
 * <P>
 * @throws TooManyListenersException if a
 * <code>DropTargetListener</code> is already added to this
 * <code>DropTarget</code>.
 */

public synchronized void addDropTargetListener(DropTargetListener dtl) throws TooManyListenersException {
    if (dtl == null) return;

    if (equals(dtl)) throw new IllegalArgumentException("DropTarget may not be its own Listener");

    if (dtListener == null)
        dtListener = dtl;
    else
        throw new TooManyListenersException();
}
 
源代码9 项目: jdk8u_jdk   文件: BeanContextServicesSupport.java
void addRequestor(Object requestor, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException {
    BeanContextServiceRevokedListener cbcsrl = (BeanContextServiceRevokedListener)requestors.get(requestor);

    if (cbcsrl != null && !cbcsrl.equals(bcsrl))
        throw new TooManyListenersException();

    requestors.put(requestor, bcsrl);
}
 
源代码10 项目: jdk8u-dev-jdk   文件: DropTarget.java
/**
 * Creates a new DropTarget given the <code>Component</code>
 * to associate itself with, an <code>int</code> representing
 * the default acceptable action(s) to
 * support, a <code>DropTargetListener</code>
 * to handle event processing, a <code>boolean</code> indicating
 * if the <code>DropTarget</code> is currently accepting drops, and
 * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c         The <code>Component</code> with which this <code>DropTarget</code> is associated
 * @param ops       The default acceptable actions for this <code>DropTarget</code>
 * @param dtl       The <code>DropTargetListener</code> for this <code>DropTarget</code>
 * @param act       Is the <code>DropTarget</code> accepting drops.
 * @param fm        The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE>
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 *            returns true
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public DropTarget(Component c, int ops, DropTargetListener dtl,
                  boolean act, FlavorMap fm)
    throws HeadlessException
{
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    component = c;

    setDefaultActions(ops);

    if (dtl != null) try {
        addDropTargetListener(dtl);
    } catch (TooManyListenersException tmle) {
        // do nothing!
    }

    if (c != null) {
        c.setDropTarget(this);
        setActive(act);
    }

    if (fm != null) {
        flavorMap = fm;
    } else {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }
}
 
源代码11 项目: jdk8u-dev-jdk   文件: Accessor.java
public void addTestListener(TestListener listener) throws TooManyListenersException {
    if (listener != null) {
        if (this.listener != null) {
            throw new TooManyListenersException();
        }
        this.listener = listener;
    }
}
 
源代码12 项目: openjdk-8-source   文件: TransferHandler.java
public void addDropTargetListener(DropTargetListener dtl) throws TooManyListenersException {
    // Since the super class only supports one DropTargetListener,
    // and we add one from the constructor, we always add to the
    // extended list.
    if (listenerList == null) {
        listenerList = new EventListenerList();
    }
    listenerList.add(DropTargetListener.class, dtl);
}
 
源代码13 项目: hottub   文件: BeanContextServicesSupport.java
void addRequestor(Object requestor, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException {
    BeanContextServiceRevokedListener cbcsrl = (BeanContextServiceRevokedListener)requestors.get(requestor);

    if (cbcsrl != null && !cbcsrl.equals(bcsrl))
        throw new TooManyListenersException();

    requestors.put(requestor, bcsrl);
}
 
源代码14 项目: JVoiceXML   文件: TimerManager.java
public void register(final String key, final TimerListener listener) throws TooManyListenersException {
  if(!listeners.containsKey(key)) {
    listeners.put(key, listener);
  } else {
    final StringBuilder buffer = new StringBuilder();
    buffer.append("There is already a listener registered for a key with the name ").append(key);
    throw new TooManyListenersException(buffer.toString());
  }
}
 
源代码15 项目: jdk1.8-source-analysis   文件: TransferHandler.java
public void addDropTargetListener(DropTargetListener dtl) throws TooManyListenersException {
    // Since the super class only supports one DropTargetListener,
    // and we add one from the constructor, we always add to the
    // extended list.
    if (listenerList == null) {
        listenerList = new EventListenerList();
    }
    listenerList.add(DropTargetListener.class, dtl);
}
 
源代码16 项目: dragonwell8_jdk   文件: DropTarget.java
/**
 * Creates a new DropTarget given the <code>Component</code>
 * to associate itself with, an <code>int</code> representing
 * the default acceptable action(s) to
 * support, a <code>DropTargetListener</code>
 * to handle event processing, a <code>boolean</code> indicating
 * if the <code>DropTarget</code> is currently accepting drops, and
 * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c         The <code>Component</code> with which this <code>DropTarget</code> is associated
 * @param ops       The default acceptable actions for this <code>DropTarget</code>
 * @param dtl       The <code>DropTargetListener</code> for this <code>DropTarget</code>
 * @param act       Is the <code>DropTarget</code> accepting drops.
 * @param fm        The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE>
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 *            returns true
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public DropTarget(Component c, int ops, DropTargetListener dtl,
                  boolean act, FlavorMap fm)
    throws HeadlessException
{
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    component = c;

    setDefaultActions(ops);

    if (dtl != null) try {
        addDropTargetListener(dtl);
    } catch (TooManyListenersException tmle) {
        // do nothing!
    }

    if (c != null) {
        c.setDropTarget(this);
        setActive(act);
    }

    if (fm != null) {
        flavorMap = fm;
    } else {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }
}
 
源代码17 项目: MtgDesktopCompanion   文件: FileDropDecorator.java
private void makeDropTarget(final Component c)
{
    final DropTarget dt = new DropTarget();
    try
    {  
    	dt.addDropTargetListener( dropListener );
    }  
    catch(TooManyListenersException e )
    {   
    	 logger.error("Do you have another listener attached ?",e);
    }  
    
    c.addHierarchyListener( ( HierarchyEvent evt )->{   
		                Component parent = c.getParent();
		                if( parent == null )
		                	c.setDropTarget( null );
		                else
		                	new DropTarget(c, dropListener);
		        });
    
    if( c.getParent() != null )
        new DropTarget(c, dropListener);
    
    if( c instanceof Container )
    {   
        Container cont = (Container) c;
        for(Component cp : cont.getComponents())
            makeDropTarget(cp );
    }  
}
 
源代码18 项目: hottub   文件: DropTarget.java
/**
 * Creates a new DropTarget given the <code>Component</code>
 * to associate itself with, an <code>int</code> representing
 * the default acceptable action(s) to
 * support, a <code>DropTargetListener</code>
 * to handle event processing, a <code>boolean</code> indicating
 * if the <code>DropTarget</code> is currently accepting drops, and
 * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c         The <code>Component</code> with which this <code>DropTarget</code> is associated
 * @param ops       The default acceptable actions for this <code>DropTarget</code>
 * @param dtl       The <code>DropTargetListener</code> for this <code>DropTarget</code>
 * @param act       Is the <code>DropTarget</code> accepting drops.
 * @param fm        The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE>
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 *            returns true
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public DropTarget(Component c, int ops, DropTargetListener dtl,
                  boolean act, FlavorMap fm)
    throws HeadlessException
{
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    component = c;

    setDefaultActions(ops);

    if (dtl != null) try {
        addDropTargetListener(dtl);
    } catch (TooManyListenersException tmle) {
        // do nothing!
    }

    if (c != null) {
        c.setDropTarget(this);
        setActive(act);
    }

    if (fm != null) {
        flavorMap = fm;
    } else {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }
}
 
源代码19 项目: openjdk-jdk8u-backup   文件: TransferHandler.java
SwingDropTarget(Component c) {
    super(c, COPY_OR_MOVE | LINK, null);
    try {
        // addDropTargetListener is overridden
        // we specifically need to add to the superclass
        super.addDropTargetListener(getDropTargetListener());
    } catch (TooManyListenersException tmle) {}
}
 
源代码20 项目: openjdk-8   文件: Accessor.java
public void addTestListener(TestListener listener) throws TooManyListenersException {
    if (listener != null) {
        if (this.listener != null) {
            throw new TooManyListenersException();
        }
        this.listener = listener;
    }
}
 
源代码21 项目: openjdk-8-source   文件: Accessor.java
public void addTestListener(TestListener listener) throws TooManyListenersException {
    if (listener != null) {
        if (this.listener != null) {
            throw new TooManyListenersException();
        }
        this.listener = listener;
    }
}
 
源代码22 项目: jdk8u-jdk   文件: BeanContextServicesSupport.java
void addRequestor(Object requestor, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException {
    BeanContextServiceRevokedListener cbcsrl = (BeanContextServiceRevokedListener)requestors.get(requestor);

    if (cbcsrl != null && !cbcsrl.equals(bcsrl))
        throw new TooManyListenersException();

    requestors.put(requestor, bcsrl);
}
 
源代码23 项目: openjdk-jdk9   文件: BeanContextServicesSupport.java
void addRequestor(Object requestor, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException {
    BeanContextServiceRevokedListener cbcsrl = requestors.get(requestor);

    if (cbcsrl != null && !cbcsrl.equals(bcsrl))
        throw new TooManyListenersException();

    requestors.put(requestor, bcsrl);
}
 
源代码24 项目: TencentKona-8   文件: BeanContextServicesSupport.java
void addRequestor(Object requestor, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException {
    BeanContextServiceRevokedListener cbcsrl = (BeanContextServiceRevokedListener)requestors.get(requestor);

    if (cbcsrl != null && !cbcsrl.equals(bcsrl))
        throw new TooManyListenersException();

    requestors.put(requestor, bcsrl);
}
 
源代码25 项目: openjdk-jdk9   文件: Accessor.java
public void addTestListener(TestListener listener) throws TooManyListenersException {
    if (listener != null) {
        if (this.listener != null) {
            throw new TooManyListenersException();
        }
        this.listener = listener;
    }
}
 
源代码26 项目: openjdk-8-source   文件: TransferHandler.java
SwingDropTarget(Component c) {
    super(c, COPY_OR_MOVE | LINK, null);
    try {
        // addDropTargetListener is overridden
        // we specifically need to add to the superclass
        super.addDropTargetListener(getDropTargetListener());
    } catch (TooManyListenersException tmle) {}
}
 
源代码27 项目: hottub   文件: TransferHandler.java
public void addDropTargetListener(DropTargetListener dtl) throws TooManyListenersException {
    // Since the super class only supports one DropTargetListener,
    // and we add one from the constructor, we always add to the
    // extended list.
    if (listenerList == null) {
        listenerList = new EventListenerList();
    }
    listenerList.add(DropTargetListener.class, dtl);
}
 
源代码28 项目: jdk8u-dev-jdk   文件: TransferHandler.java
SwingDropTarget(Component c) {
    super(c, COPY_OR_MOVE | LINK, null);
    try {
        // addDropTargetListener is overridden
        // we specifically need to add to the superclass
        super.addDropTargetListener(getDropTargetListener());
    } catch (TooManyListenersException tmle) {}
}
 
源代码29 项目: meshnet   文件: SerialRXTXComm.java
public SerialRXTXComm(CommPortIdentifier portIdentifier, Layer3Base layer3) throws NoSuchPortException, PortInUseException, UnsupportedCommOperationException, IOException, TooManyListenersException{

		if (portIdentifier.isCurrentlyOwned()) {
			throw new IOException("Port is currently in use");
		} else {
			CommPort commPort = portIdentifier.open(this.getClass().getName(),
					TIME_OUT);

			if (commPort instanceof SerialPort) {
				SerialPort serialPort = (SerialPort) commPort;
				serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
						SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);

				inStream = serialPort.getInputStream();
				outStream = serialPort.getOutputStream();

				new SerialReceiver().start();

				/*serialPort.addEventListener(this);
				serialPort.notifyOnDataAvailable(true);*/

			} else {
				throw new IOException("This is not a serial port!.");
			}
		}
		
		this.layer2 = new Layer2Serial(this, layer3);
	}
 
源代码30 项目: openjdk-jdk8u-backup   文件: DropTarget.java
/**
 * Adds a new <code>DropTargetListener</code> (UNICAST SOURCE).
 * <P>
 * @param dtl The new <code>DropTargetListener</code>
 * <P>
 * @throws TooManyListenersException if a
 * <code>DropTargetListener</code> is already added to this
 * <code>DropTarget</code>.
 */

public synchronized void addDropTargetListener(DropTargetListener dtl) throws TooManyListenersException {
    if (dtl == null) return;

    if (equals(dtl)) throw new IllegalArgumentException("DropTarget may not be its own Listener");

    if (dtListener == null)
        dtListener = dtl;
    else
        throw new TooManyListenersException();
}
 
 类所在包
 类方法
 同包方法