java.util.TooManyListenersException Java Examples

The following examples show how to use java.util.TooManyListenersException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SerialSketchUploader.java    From arduino-remote-uploader with GNU General Public License v2.0 8 votes vote down vote up
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);
}
 
Example #2
Source File: BeanContextServicesSupport.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #3
Source File: mxGraphHandler.java    From blog-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 
 */
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);
	}
}
 
Example #4
Source File: ExplorerDragSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** 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);
    }
}
 
Example #5
Source File: TraceTabbedPane.java    From pega-tracerviewer with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example #6
Source File: TransferHandler.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
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);
}
 
Example #7
Source File: BeanContextServicesSupport.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector) {
    Object service = null;

    try {
        service = nestingCtxt.getService(bcs, requestor, serviceClass, serviceSelector, this);
    } catch (TooManyListenersException tmle) {
        return null;
    }

    return service;
}
 
Example #8
Source File: BeanContextServicesSupport.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector) {
    Object service = null;

    try {
        service = nestingCtxt.getService(bcs, requestor, serviceClass, serviceSelector, this);
    } catch (TooManyListenersException tmle) {
        return null;
    }

    return service;
}
 
Example #9
Source File: DropTarget.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example #10
Source File: TransferHandler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #11
Source File: BeanContextServicesSupport.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector) {
    Object service = null;

    try {
        service = nestingCtxt.getService(bcs, requestor, serviceClass, serviceSelector, this);
    } catch (TooManyListenersException tmle) {
        return null;
    }

    return service;
}
 
Example #12
Source File: SerialPortManager.java    From SerialPortDemo with Apache License 2.0 5 votes vote down vote up
/**
 * 添加监听器
 * 
 * @param port
 *            串口对象
 * @param listener
 *            串口存在有效数据监听
 */
public static void addListener(SerialPort serialPort, DataAvailableListener listener) {
	try {
		// 给串口添加监听器
		serialPort.addEventListener(new SerialPortListener(listener));
		// 设置当有数据到达时唤醒监听接收线程
		serialPort.notifyOnDataAvailable(true);
		// 设置当通信中断时唤醒中断线程
		serialPort.notifyOnBreakInterrupt(true);
	} catch (TooManyListenersException e) {
		e.printStackTrace();
	}
}
 
Example #13
Source File: mxGraphHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 *
 */
protected void installDropTargetHandler() {
  DropTarget dropTarget = graphComponent.getDropTarget();

  try {
    if (dropTarget != null) {
      dropTarget.addDropTargetListener(this);
      currentDropTarget = dropTarget;
    }
  }
  catch (TooManyListenersException tmle) {
    // should not happen... swing drop target is multicast
  }
}
 
Example #14
Source File: TransferHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #15
Source File: SerialPortImpl.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void addEventListener(SerialPortEventListener listener) throws TooManyListenersException {
    sp.addEventListener(new javax.comm.SerialPortEventListener() {
        @Override
        public void serialEvent(final @Nullable SerialPortEvent event) {
            if (event == null) {
                return;
            }
            listener.serialEvent(new SerialPortEventImpl(event));
        }
    });
}
 
Example #16
Source File: DropTarget.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example #17
Source File: ProcessRendererDropTarget.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void addDropTargetListener(final DropTargetListener dtl) throws TooManyListenersException {
	if (dropTragetListenerList == null) {
		dropTragetListenerList = new EventListenerList();
	}
	dropTragetListenerList.add(DropTargetListener.class, dtl);
}
 
Example #18
Source File: DarkTabFrameUI.java    From darklaf with MIT License 5 votes vote down vote up
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();
    }
}
 
Example #19
Source File: Accessor.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void addTestListener(TestListener listener) throws TooManyListenersException {
    if (listener != null) {
        if (this.listener != null) {
            throw new TooManyListenersException();
        }
        this.listener = listener;
    }
}
 
Example #20
Source File: DropTarget.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example #21
Source File: TransferHandler.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
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) {}
}
 
Example #22
Source File: SerialConnector.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Set the serial event handler
 */
private void setSerialEventHandler(SerialPortEventListener serialPortEventListenser) {
    try {
        // Add the serial port event listener
        serialPort.addEventListener(serialPortEventListenser);
        serialPort.notifyOnDataAvailable(true);
    } catch (TooManyListenersException tooManyListenersException) {
        logger.error("open(): Too Many Listeners Exception: ", tooManyListenersException);
    }
}
 
Example #23
Source File: BeanContextServicesSupport.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector) {
    Object service = null;

    try {
        service = nestingCtxt.getService(bcs, requestor, serviceClass, serviceSelector, this);
    } catch (TooManyListenersException tmle) {
        return null;
    }

    return service;
}
 
Example #24
Source File: Accessor.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void addTestListener(TestListener listener) throws TooManyListenersException {
    if (listener != null) {
        if (this.listener != null) {
            throw new TooManyListenersException();
        }
        this.listener = listener;
    }
}
 
Example #25
Source File: DropTarget.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #26
Source File: SerialRXTXComm.java    From meshnet with GNU General Public License v3.0 5 votes vote down vote up
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);
	}
 
Example #27
Source File: TransferHandler.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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) {}
}
 
Example #28
Source File: TransferHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #29
Source File: TransferHandler.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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) {}
}
 
Example #30
Source File: Accessor.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void addTestListener(TestListener listener) throws TooManyListenersException {
    if (listener != null) {
        if (this.listener != null) {
            throw new TooManyListenersException();
        }
        this.listener = listener;
    }
}