Java Code Examples for java.awt.Component#setDropTarget()

The following examples show how to use java.awt.Component#setDropTarget() . These examples are extracted from open source projects. 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 Project: ghidra   File: FileOpenDropHandler.java    License: Apache License 2.0 6 votes vote down vote up
private void deinitializeComponents(Component comp) {
	if (comp instanceof CellRendererPane) {
		return;
	}

	if (comp instanceof Container) {
		Container c = (Container) comp;
		c.removeContainerListener(this);
		Component comps[] = c.getComponents();
		for (Component element : comps) {
			deinitializeComponents(element);
		}
	}
	DropTarget dt = comp.getDropTarget();
	if (dt instanceof CascadedDropTarget) {
		CascadedDropTarget target = (CascadedDropTarget) dt;
		DropTarget newTarget = target.removeDropTarget(globalDropTarget);
		comp.setDropTarget(newTarget);
	}
}
 
Example 2
Source Project: Bytecoder   File: DropTarget.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Note: this interface is required to permit the safe association
 * of a DropTarget with a Component in one of two ways, either:
 * {@code component.setDropTarget(droptarget);}
 * or {@code droptarget.setComponent(component);}
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c The new {@code Component} this {@code DropTarget}
 * is to be associated with.
 */

public synchronized void setComponent(Component c) {
    if (component == c || component != null && component.equals(c))
        return;

    final Component old = component;

    if (old  != null) {
        clearAutoscroll();

        component = null;
        removeNotify();
        old.setDropTarget(null);

    }

    if ((component = c) != null) try {
        c.setDropTarget(this);
    } catch (Exception e) { // undo the change
        if (old != null) {
            old.setDropTarget(this);
            addNotify();
        }
    }
}
 
Example 3
/**
 * 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 4
/**
 * Note: this interface is required to permit the safe association
 * of a DropTarget with a Component in one of two ways, either:
 * <code> component.setDropTarget(droptarget); </code>
 * or <code> droptarget.setComponent(component); </code>
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c The new <code>Component</code> this <code>DropTarget</code>
 * is to be associated with.
 */

public synchronized void setComponent(Component c) {
    if (component == c || component != null && component.equals(c))
        return;

    Component     old;
    ComponentPeer oldPeer = null;

    if ((old = component) != null) {
        clearAutoscroll();

        component = null;

        if (componentPeer != null) {
            oldPeer = componentPeer;
            removeNotify(componentPeer);
        }

        old.setDropTarget(null);

    }

    if ((component = c) != null) try {
        c.setDropTarget(this);
    } catch (Exception e) { // undo the change
        if (old != null) {
            old.setDropTarget(this);
            addNotify(oldPeer);
        }
    }
}
 
Example 5
/**
 * 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 6
/**
 * Note: this interface is required to permit the safe association
 * of a DropTarget with a Component in one of two ways, either:
 * <code> component.setDropTarget(droptarget); </code>
 * or <code> droptarget.setComponent(component); </code>
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c The new <code>Component</code> this <code>DropTarget</code>
 * is to be associated with.
 */

public synchronized void setComponent(Component c) {
    if (component == c || component != null && component.equals(c))
        return;

    Component     old;
    ComponentPeer oldPeer = null;

    if ((old = component) != null) {
        clearAutoscroll();

        component = null;

        if (componentPeer != null) {
            oldPeer = componentPeer;
            removeNotify(componentPeer);
        }

        old.setDropTarget(null);

    }

    if ((component = c) != null) try {
        c.setDropTarget(this);
    } catch (Exception e) { // undo the change
        if (old != null) {
            old.setDropTarget(this);
            addNotify(oldPeer);
        }
    }
}
 
Example 7
public static boolean remove( Component c, boolean recursive )
{ 
        c.setDropTarget( null );
        if( recursive && ( c instanceof Container ) )
        {   Component[] comps = ((Container)c).getComponents();
            for( int i = 0; i < comps.length; i++ )
                remove( comps[i], recursive );
            return true;
        } 
        else 
    	{
        	return false;
    	}
}
 
Example 8
/**
 * Note: this interface is required to permit the safe association
 * of a DropTarget with a Component in one of two ways, either:
 * <code> component.setDropTarget(droptarget); </code>
 * or <code> droptarget.setComponent(component); </code>
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c The new <code>Component</code> this <code>DropTarget</code>
 * is to be associated with.
 */

public synchronized void setComponent(Component c) {
    if (component == c || component != null && component.equals(c))
        return;

    Component     old;
    ComponentPeer oldPeer = null;

    if ((old = component) != null) {
        clearAutoscroll();

        component = null;

        if (componentPeer != null) {
            oldPeer = componentPeer;
            removeNotify(componentPeer);
        }

        old.setDropTarget(null);

    }

    if ((component = c) != null) try {
        c.setDropTarget(this);
    } catch (Exception e) { // undo the change
        if (old != null) {
            old.setDropTarget(this);
            addNotify(oldPeer);
        }
    }
}
 
Example 9
/**
 * 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
/**
 * 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 11
Source Project: Java8CN   File: DropTarget.java    License: Apache License 2.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 12
Source Project: JDKSourceCode1.8   File: DropTarget.java    License: MIT License 5 votes vote down vote up
/**
 * Note: this interface is required to permit the safe association
 * of a DropTarget with a Component in one of two ways, either:
 * <code> component.setDropTarget(droptarget); </code>
 * or <code> droptarget.setComponent(component); </code>
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c The new <code>Component</code> this <code>DropTarget</code>
 * is to be associated with.
 */

public synchronized void setComponent(Component c) {
    if (component == c || component != null && component.equals(c))
        return;

    Component     old;
    ComponentPeer oldPeer = null;

    if ((old = component) != null) {
        clearAutoscroll();

        component = null;

        if (componentPeer != null) {
            oldPeer = componentPeer;
            removeNotify(componentPeer);
        }

        old.setDropTarget(null);

    }

    if ((component = c) != null) try {
        c.setDropTarget(this);
    } catch (Exception e) { // undo the change
        if (old != null) {
            old.setDropTarget(this);
            addNotify(oldPeer);
        }
    }
}
 
Example 13
/**
 * 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 14
/**
 * 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 15
/**
 * 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 16
/**
 * Note: this interface is required to permit the safe association
 * of a DropTarget with a Component in one of two ways, either:
 * <code> component.setDropTarget(droptarget); </code>
 * or <code> droptarget.setComponent(component); </code>
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c The new <code>Component</code> this <code>DropTarget</code>
 * is to be associated with.
 */

public synchronized void setComponent(Component c) {
    if (component == c || component != null && component.equals(c))
        return;

    Component     old;
    ComponentPeer oldPeer = null;

    if ((old = component) != null) {
        clearAutoscroll();

        component = null;

        if (componentPeer != null) {
            oldPeer = componentPeer;
            removeNotify(componentPeer);
        }

        old.setDropTarget(null);

    }

    if ((component = c) != null) try {
        c.setDropTarget(this);
    } catch (Exception e) { // undo the change
        if (old != null) {
            old.setDropTarget(this);
            addNotify(oldPeer);
        }
    }
}
 
Example 17
Source Project: hottub   File: DropTarget.java    License: 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 18
Source Project: hottub   File: DropTarget.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Note: this interface is required to permit the safe association
 * of a DropTarget with a Component in one of two ways, either:
 * <code> component.setDropTarget(droptarget); </code>
 * or <code> droptarget.setComponent(component); </code>
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c The new <code>Component</code> this <code>DropTarget</code>
 * is to be associated with.
 */

public synchronized void setComponent(Component c) {
    if (component == c || component != null && component.equals(c))
        return;

    Component     old;
    ComponentPeer oldPeer = null;

    if ((old = component) != null) {
        clearAutoscroll();

        component = null;

        if (componentPeer != null) {
            oldPeer = componentPeer;
            removeNotify(componentPeer);
        }

        old.setDropTarget(null);

    }

    if ((component = c) != null) try {
        c.setDropTarget(this);
    } catch (Exception e) { // undo the change
        if (old != null) {
            old.setDropTarget(this);
            addNotify(oldPeer);
        }
    }
}
 
Example 19
/**
 * Note: this interface is required to permit the safe association
 * of a DropTarget with a Component in one of two ways, either:
 * <code> component.setDropTarget(droptarget); </code>
 * or <code> droptarget.setComponent(component); </code>
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c The new <code>Component</code> this <code>DropTarget</code>
 * is to be associated with.
 */

public synchronized void setComponent(Component c) {
    if (component == c || component != null && component.equals(c))
        return;

    Component     old;
    ComponentPeer oldPeer = null;

    if ((old = component) != null) {
        clearAutoscroll();

        component = null;

        if (componentPeer != null) {
            oldPeer = componentPeer;
            removeNotify(componentPeer);
        }

        old.setDropTarget(null);

    }

    if ((component = c) != null) try {
        c.setDropTarget(this);
    } catch (Exception e) { // undo the change
        if (old != null) {
            old.setDropTarget(this);
            addNotify(oldPeer);
        }
    }
}
 
Example 20
/**
 * 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();
    }
}