类java.awt.datatransfer.FlavorMap源码实例Demo

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

源代码1 项目: 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();
    }
}
 
源代码2 项目: openjdk-8   文件: DragSource.java
/**
 * Deserializes this <code>DragSource</code>. This method first performs
 * default deserialization. Next, this object's <code>FlavorMap</code> is
 * deserialized by using the next object in the stream.
 * If the resulting <code>FlavorMap</code> is <code>null</code>, this
 * object's <code>FlavorMap</code> is set to the default FlavorMap for
 * this thread's <code>ClassLoader</code>.
 * Next, this object's listeners are deserialized by reading a
 * <code>null</code>-terminated sequence of 0 or more key/value pairs
 * from the stream:
 * <ul>
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is
 * deserialized using the corresponding value object and added to this
 * <code>DragSource</code>.
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceMotionListenerK</code>, a
 * <code>DragSourceMotionListener</code> is deserialized using the
 * corresponding value object and added to this <code>DragSource</code>.
 * <li>Otherwise, the key/value pair is skipped.
 * </ul>
 *
 * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
 * @since 1.4
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException {
    s.defaultReadObject();

    // 'flavorMap' was written explicitly
    flavorMap = (FlavorMap)s.readObject();

    // Implementation assumes 'flavorMap' is never null.
    if (flavorMap == null) {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
        String key = ((String)keyOrNull).intern();

        if (dragSourceListenerK == key) {
            addDragSourceListener((DragSourceListener)(s.readObject()));
        } else if (dragSourceMotionListenerK == key) {
            addDragSourceMotionListener(
                (DragSourceMotionListener)(s.readObject()));
        } else {
            // skip value for unrecognized key
            s.readObject();
        }
    }
}
 
源代码3 项目: jdk1.8-source-analysis   文件: DragSource.java
/**
 * Start a drag, given the <code>DragGestureEvent</code>
 * that initiated the drag, the initial
 * <code>Cursor</code> to use,
 * the <code>Image</code> to drag,
 * the offset of the <code>Image</code> origin
 * from the hotspot of the <code>Cursor</code> at
 * the instant of the trigger,
 * the <code>Transferable</code> subject data
 * of the drag, the <code>DragSourceListener</code>,
 * and the <code>FlavorMap</code>.
 * <P>
 * @param trigger        the <code>DragGestureEvent</code> that initiated the drag
 * @param dragCursor     the initial {@code Cursor} for this drag operation
 *                       or {@code null} for the default cursor handling;
 *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
 *                       for more details on the cursor handling mechanism during drag and drop
 * @param dragImage      the image to drag or {@code null}
 * @param imageOffset    the offset of the <code>Image</code> origin from the hotspot
 *                       of the <code>Cursor</code> at the instant of the trigger
 * @param transferable   the subject data of the drag
 * @param dsl            the <code>DragSourceListener</code>
 * @param flavorMap      the <code>FlavorMap</code> to use, or <code>null</code>
 * <P>
 * @throws java.awt.dnd.InvalidDnDOperationException
 *    if the Drag and Drop
 *    system is unable to initiate a drag operation, or if the user
 *    attempts to start a drag while an existing drag operation
 *    is still executing
 */

public void startDrag(DragGestureEvent   trigger,
                      Cursor             dragCursor,
                      Image              dragImage,
                      Point              imageOffset,
                      Transferable       transferable,
                      DragSourceListener dsl,
                      FlavorMap          flavorMap) throws InvalidDnDOperationException {

    SunDragSourceContextPeer.setDragDropInProgress(true);

    try {
        if (flavorMap != null) this.flavorMap = flavorMap;

        DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);

        DragSourceContext     dsc = createDragSourceContext(dscp,
                                                            trigger,
                                                            dragCursor,
                                                            dragImage,
                                                            imageOffset,
                                                            transferable,
                                                            dsl
                                                            );

        if (dsc == null) {
            throw new InvalidDnDOperationException();
        }

        dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
    } catch (RuntimeException e) {
        SunDragSourceContextPeer.setDragDropInProgress(false);
        throw e;
    }
}
 
源代码4 项目: 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();
    }
}
 
源代码5 项目: dragonwell8_jdk   文件: DragSource.java
/**
 * Start a drag, given the <code>DragGestureEvent</code>
 * that initiated the drag, the initial
 * <code>Cursor</code> to use,
 * the <code>Image</code> to drag,
 * the offset of the <code>Image</code> origin
 * from the hotspot of the <code>Cursor</code> at
 * the instant of the trigger,
 * the <code>Transferable</code> subject data
 * of the drag, the <code>DragSourceListener</code>,
 * and the <code>FlavorMap</code>.
 * <P>
 * @param trigger        the <code>DragGestureEvent</code> that initiated the drag
 * @param dragCursor     the initial {@code Cursor} for this drag operation
 *                       or {@code null} for the default cursor handling;
 *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
 *                       for more details on the cursor handling mechanism during drag and drop
 * @param dragImage      the image to drag or {@code null}
 * @param imageOffset    the offset of the <code>Image</code> origin from the hotspot
 *                       of the <code>Cursor</code> at the instant of the trigger
 * @param transferable   the subject data of the drag
 * @param dsl            the <code>DragSourceListener</code>
 * @param flavorMap      the <code>FlavorMap</code> to use, or <code>null</code>
 * <P>
 * @throws java.awt.dnd.InvalidDnDOperationException
 *    if the Drag and Drop
 *    system is unable to initiate a drag operation, or if the user
 *    attempts to start a drag while an existing drag operation
 *    is still executing
 */

public void startDrag(DragGestureEvent   trigger,
                      Cursor             dragCursor,
                      Image              dragImage,
                      Point              imageOffset,
                      Transferable       transferable,
                      DragSourceListener dsl,
                      FlavorMap          flavorMap) throws InvalidDnDOperationException {

    SunDragSourceContextPeer.setDragDropInProgress(true);

    try {
        if (flavorMap != null) this.flavorMap = flavorMap;

        DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);

        DragSourceContext     dsc = createDragSourceContext(dscp,
                                                            trigger,
                                                            dragCursor,
                                                            dragImage,
                                                            imageOffset,
                                                            transferable,
                                                            dsl
                                                            );

        if (dsc == null) {
            throw new InvalidDnDOperationException();
        }

        dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
    } catch (RuntimeException e) {
        SunDragSourceContextPeer.setDragDropInProgress(false);
        throw e;
    }
}
 
源代码6 项目: dragonwell8_jdk   文件: DragSource.java
/**
 * Deserializes this <code>DragSource</code>. This method first performs
 * default deserialization. Next, this object's <code>FlavorMap</code> is
 * deserialized by using the next object in the stream.
 * If the resulting <code>FlavorMap</code> is <code>null</code>, this
 * object's <code>FlavorMap</code> is set to the default FlavorMap for
 * this thread's <code>ClassLoader</code>.
 * Next, this object's listeners are deserialized by reading a
 * <code>null</code>-terminated sequence of 0 or more key/value pairs
 * from the stream:
 * <ul>
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is
 * deserialized using the corresponding value object and added to this
 * <code>DragSource</code>.
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceMotionListenerK</code>, a
 * <code>DragSourceMotionListener</code> is deserialized using the
 * corresponding value object and added to this <code>DragSource</code>.
 * <li>Otherwise, the key/value pair is skipped.
 * </ul>
 *
 * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
 * @since 1.4
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException {
    s.defaultReadObject();

    // 'flavorMap' was written explicitly
    flavorMap = (FlavorMap)s.readObject();

    // Implementation assumes 'flavorMap' is never null.
    if (flavorMap == null) {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
        String key = ((String)keyOrNull).intern();

        if (dragSourceListenerK == key) {
            addDragSourceListener((DragSourceListener)(s.readObject()));
        } else if (dragSourceMotionListenerK == key) {
            addDragSourceMotionListener(
                (DragSourceMotionListener)(s.readObject()));
        } else {
            // skip value for unrecognized key
            s.readObject();
        }
    }
}
 
源代码7 项目: TencentKona-8   文件: 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 项目: jdk8u_jdk   文件: DragSource.java
/**
 * Deserializes this <code>DragSource</code>. This method first performs
 * default deserialization. Next, this object's <code>FlavorMap</code> is
 * deserialized by using the next object in the stream.
 * If the resulting <code>FlavorMap</code> is <code>null</code>, this
 * object's <code>FlavorMap</code> is set to the default FlavorMap for
 * this thread's <code>ClassLoader</code>.
 * Next, this object's listeners are deserialized by reading a
 * <code>null</code>-terminated sequence of 0 or more key/value pairs
 * from the stream:
 * <ul>
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is
 * deserialized using the corresponding value object and added to this
 * <code>DragSource</code>.
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceMotionListenerK</code>, a
 * <code>DragSourceMotionListener</code> is deserialized using the
 * corresponding value object and added to this <code>DragSource</code>.
 * <li>Otherwise, the key/value pair is skipped.
 * </ul>
 *
 * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
 * @since 1.4
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException {
    s.defaultReadObject();

    // 'flavorMap' was written explicitly
    flavorMap = (FlavorMap)s.readObject();

    // Implementation assumes 'flavorMap' is never null.
    if (flavorMap == null) {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
        String key = ((String)keyOrNull).intern();

        if (dragSourceListenerK == key) {
            addDragSourceListener((DragSourceListener)(s.readObject()));
        } else if (dragSourceMotionListenerK == key) {
            addDragSourceMotionListener(
                (DragSourceMotionListener)(s.readObject()));
        } else {
            // skip value for unrecognized key
            s.readObject();
        }
    }
}
 
源代码9 项目: openjdk-8-source   文件: DragSource.java
/**
 * Deserializes this <code>DragSource</code>. This method first performs
 * default deserialization. Next, this object's <code>FlavorMap</code> is
 * deserialized by using the next object in the stream.
 * If the resulting <code>FlavorMap</code> is <code>null</code>, this
 * object's <code>FlavorMap</code> is set to the default FlavorMap for
 * this thread's <code>ClassLoader</code>.
 * Next, this object's listeners are deserialized by reading a
 * <code>null</code>-terminated sequence of 0 or more key/value pairs
 * from the stream:
 * <ul>
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is
 * deserialized using the corresponding value object and added to this
 * <code>DragSource</code>.
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceMotionListenerK</code>, a
 * <code>DragSourceMotionListener</code> is deserialized using the
 * corresponding value object and added to this <code>DragSource</code>.
 * <li>Otherwise, the key/value pair is skipped.
 * </ul>
 *
 * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
 * @since 1.4
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException {
    s.defaultReadObject();

    // 'flavorMap' was written explicitly
    flavorMap = (FlavorMap)s.readObject();

    // Implementation assumes 'flavorMap' is never null.
    if (flavorMap == null) {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
        String key = ((String)keyOrNull).intern();

        if (dragSourceListenerK == key) {
            addDragSourceListener((DragSourceListener)(s.readObject()));
        } else if (dragSourceMotionListenerK == key) {
            addDragSourceMotionListener(
                (DragSourceMotionListener)(s.readObject()));
        } else {
            // skip value for unrecognized key
            s.readObject();
        }
    }
}
 
源代码10 项目: jdk8u60   文件: 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_jdk   文件: DragSource.java
/**
 * Start a drag, given the <code>DragGestureEvent</code>
 * that initiated the drag, the initial
 * <code>Cursor</code> to use,
 * the <code>Image</code> to drag,
 * the offset of the <code>Image</code> origin
 * from the hotspot of the <code>Cursor</code> at
 * the instant of the trigger,
 * the <code>Transferable</code> subject data
 * of the drag, the <code>DragSourceListener</code>,
 * and the <code>FlavorMap</code>.
 * <P>
 * @param trigger        the <code>DragGestureEvent</code> that initiated the drag
 * @param dragCursor     the initial {@code Cursor} for this drag operation
 *                       or {@code null} for the default cursor handling;
 *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
 *                       for more details on the cursor handling mechanism during drag and drop
 * @param dragImage      the image to drag or {@code null}
 * @param imageOffset    the offset of the <code>Image</code> origin from the hotspot
 *                       of the <code>Cursor</code> at the instant of the trigger
 * @param transferable   the subject data of the drag
 * @param dsl            the <code>DragSourceListener</code>
 * @param flavorMap      the <code>FlavorMap</code> to use, or <code>null</code>
 * <P>
 * @throws java.awt.dnd.InvalidDnDOperationException
 *    if the Drag and Drop
 *    system is unable to initiate a drag operation, or if the user
 *    attempts to start a drag while an existing drag operation
 *    is still executing
 */

public void startDrag(DragGestureEvent   trigger,
                      Cursor             dragCursor,
                      Image              dragImage,
                      Point              imageOffset,
                      Transferable       transferable,
                      DragSourceListener dsl,
                      FlavorMap          flavorMap) throws InvalidDnDOperationException {

    SunDragSourceContextPeer.setDragDropInProgress(true);

    try {
        if (flavorMap != null) this.flavorMap = flavorMap;

        DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);

        DragSourceContext     dsc = createDragSourceContext(dscp,
                                                            trigger,
                                                            dragCursor,
                                                            dragImage,
                                                            imageOffset,
                                                            transferable,
                                                            dsl
                                                            );

        if (dsc == null) {
            throw new InvalidDnDOperationException();
        }

        dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
    } catch (RuntimeException e) {
        SunDragSourceContextPeer.setDragDropInProgress(false);
        throw e;
    }
}
 
源代码12 项目: jdk8u60   文件: DragSource.java
/**
 * Start a drag, given the <code>DragGestureEvent</code>
 * that initiated the drag, the initial
 * <code>Cursor</code> to use,
 * the <code>Image</code> to drag,
 * the offset of the <code>Image</code> origin
 * from the hotspot of the <code>Cursor</code> at
 * the instant of the trigger,
 * the <code>Transferable</code> subject data
 * of the drag, the <code>DragSourceListener</code>,
 * and the <code>FlavorMap</code>.
 * <P>
 * @param trigger        the <code>DragGestureEvent</code> that initiated the drag
 * @param dragCursor     the initial {@code Cursor} for this drag operation
 *                       or {@code null} for the default cursor handling;
 *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
 *                       for more details on the cursor handling mechanism during drag and drop
 * @param dragImage      the image to drag or {@code null}
 * @param imageOffset    the offset of the <code>Image</code> origin from the hotspot
 *                       of the <code>Cursor</code> at the instant of the trigger
 * @param transferable   the subject data of the drag
 * @param dsl            the <code>DragSourceListener</code>
 * @param flavorMap      the <code>FlavorMap</code> to use, or <code>null</code>
 * <P>
 * @throws java.awt.dnd.InvalidDnDOperationException
 *    if the Drag and Drop
 *    system is unable to initiate a drag operation, or if the user
 *    attempts to start a drag while an existing drag operation
 *    is still executing
 */

public void startDrag(DragGestureEvent   trigger,
                      Cursor             dragCursor,
                      Image              dragImage,
                      Point              imageOffset,
                      Transferable       transferable,
                      DragSourceListener dsl,
                      FlavorMap          flavorMap) throws InvalidDnDOperationException {

    SunDragSourceContextPeer.setDragDropInProgress(true);

    try {
        if (flavorMap != null) this.flavorMap = flavorMap;

        DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);

        DragSourceContext     dsc = createDragSourceContext(dscp,
                                                            trigger,
                                                            dragCursor,
                                                            dragImage,
                                                            imageOffset,
                                                            transferable,
                                                            dsl
                                                            );

        if (dsc == null) {
            throw new InvalidDnDOperationException();
        }

        dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
    } catch (RuntimeException e) {
        SunDragSourceContextPeer.setDragDropInProgress(false);
        throw e;
    }
}
 
源代码13 项目: jdk8u60   文件: DragSource.java
/**
 * Deserializes this <code>DragSource</code>. This method first performs
 * default deserialization. Next, this object's <code>FlavorMap</code> is
 * deserialized by using the next object in the stream.
 * If the resulting <code>FlavorMap</code> is <code>null</code>, this
 * object's <code>FlavorMap</code> is set to the default FlavorMap for
 * this thread's <code>ClassLoader</code>.
 * Next, this object's listeners are deserialized by reading a
 * <code>null</code>-terminated sequence of 0 or more key/value pairs
 * from the stream:
 * <ul>
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is
 * deserialized using the corresponding value object and added to this
 * <code>DragSource</code>.
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceMotionListenerK</code>, a
 * <code>DragSourceMotionListener</code> is deserialized using the
 * corresponding value object and added to this <code>DragSource</code>.
 * <li>Otherwise, the key/value pair is skipped.
 * </ul>
 *
 * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
 * @since 1.4
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException {
    s.defaultReadObject();

    // 'flavorMap' was written explicitly
    flavorMap = (FlavorMap)s.readObject();

    // Implementation assumes 'flavorMap' is never null.
    if (flavorMap == null) {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
        String key = ((String)keyOrNull).intern();

        if (dragSourceListenerK == key) {
            addDragSourceListener((DragSourceListener)(s.readObject()));
        } else if (dragSourceMotionListenerK == key) {
            addDragSourceMotionListener(
                (DragSourceMotionListener)(s.readObject()));
        } else {
            // skip value for unrecognized key
            s.readObject();
        }
    }
}
 
源代码14 项目: JDKSourceCode1.8   文件: 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();
    }
}
 
源代码15 项目: hottub   文件: DragSource.java
/**
 * Start a drag, given the <code>DragGestureEvent</code>
 * that initiated the drag, the initial
 * <code>Cursor</code> to use,
 * the <code>Image</code> to drag,
 * the offset of the <code>Image</code> origin
 * from the hotspot of the <code>Cursor</code> at
 * the instant of the trigger,
 * the <code>Transferable</code> subject data
 * of the drag, the <code>DragSourceListener</code>,
 * and the <code>FlavorMap</code>.
 * <P>
 * @param trigger        the <code>DragGestureEvent</code> that initiated the drag
 * @param dragCursor     the initial {@code Cursor} for this drag operation
 *                       or {@code null} for the default cursor handling;
 *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
 *                       for more details on the cursor handling mechanism during drag and drop
 * @param dragImage      the image to drag or {@code null}
 * @param imageOffset    the offset of the <code>Image</code> origin from the hotspot
 *                       of the <code>Cursor</code> at the instant of the trigger
 * @param transferable   the subject data of the drag
 * @param dsl            the <code>DragSourceListener</code>
 * @param flavorMap      the <code>FlavorMap</code> to use, or <code>null</code>
 * <P>
 * @throws java.awt.dnd.InvalidDnDOperationException
 *    if the Drag and Drop
 *    system is unable to initiate a drag operation, or if the user
 *    attempts to start a drag while an existing drag operation
 *    is still executing
 */

public void startDrag(DragGestureEvent   trigger,
                      Cursor             dragCursor,
                      Image              dragImage,
                      Point              imageOffset,
                      Transferable       transferable,
                      DragSourceListener dsl,
                      FlavorMap          flavorMap) throws InvalidDnDOperationException {

    SunDragSourceContextPeer.setDragDropInProgress(true);

    try {
        if (flavorMap != null) this.flavorMap = flavorMap;

        DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);

        DragSourceContext     dsc = createDragSourceContext(dscp,
                                                            trigger,
                                                            dragCursor,
                                                            dragImage,
                                                            imageOffset,
                                                            transferable,
                                                            dsl
                                                            );

        if (dsc == null) {
            throw new InvalidDnDOperationException();
        }

        dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
    } catch (RuntimeException e) {
        SunDragSourceContextPeer.setDragDropInProgress(false);
        throw e;
    }
}
 
源代码16 项目: openjdk-jdk8u   文件: 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 项目: openjdk-jdk8u   文件: DragSource.java
/**
 * Start a drag, given the <code>DragGestureEvent</code>
 * that initiated the drag, the initial
 * <code>Cursor</code> to use,
 * the <code>Image</code> to drag,
 * the offset of the <code>Image</code> origin
 * from the hotspot of the <code>Cursor</code> at
 * the instant of the trigger,
 * the <code>Transferable</code> subject data
 * of the drag, the <code>DragSourceListener</code>,
 * and the <code>FlavorMap</code>.
 * <P>
 * @param trigger        the <code>DragGestureEvent</code> that initiated the drag
 * @param dragCursor     the initial {@code Cursor} for this drag operation
 *                       or {@code null} for the default cursor handling;
 *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
 *                       for more details on the cursor handling mechanism during drag and drop
 * @param dragImage      the image to drag or {@code null}
 * @param imageOffset    the offset of the <code>Image</code> origin from the hotspot
 *                       of the <code>Cursor</code> at the instant of the trigger
 * @param transferable   the subject data of the drag
 * @param dsl            the <code>DragSourceListener</code>
 * @param flavorMap      the <code>FlavorMap</code> to use, or <code>null</code>
 * <P>
 * @throws java.awt.dnd.InvalidDnDOperationException
 *    if the Drag and Drop
 *    system is unable to initiate a drag operation, or if the user
 *    attempts to start a drag while an existing drag operation
 *    is still executing
 */

public void startDrag(DragGestureEvent   trigger,
                      Cursor             dragCursor,
                      Image              dragImage,
                      Point              imageOffset,
                      Transferable       transferable,
                      DragSourceListener dsl,
                      FlavorMap          flavorMap) throws InvalidDnDOperationException {

    SunDragSourceContextPeer.setDragDropInProgress(true);

    try {
        if (flavorMap != null) this.flavorMap = flavorMap;

        DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);

        DragSourceContext     dsc = createDragSourceContext(dscp,
                                                            trigger,
                                                            dragCursor,
                                                            dragImage,
                                                            imageOffset,
                                                            transferable,
                                                            dsl
                                                            );

        if (dsc == null) {
            throw new InvalidDnDOperationException();
        }

        dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
    } catch (RuntimeException e) {
        SunDragSourceContextPeer.setDragDropInProgress(false);
        throw e;
    }
}
 
源代码18 项目: openjdk-jdk8u   文件: DragSource.java
/**
 * Deserializes this <code>DragSource</code>. This method first performs
 * default deserialization. Next, this object's <code>FlavorMap</code> is
 * deserialized by using the next object in the stream.
 * If the resulting <code>FlavorMap</code> is <code>null</code>, this
 * object's <code>FlavorMap</code> is set to the default FlavorMap for
 * this thread's <code>ClassLoader</code>.
 * Next, this object's listeners are deserialized by reading a
 * <code>null</code>-terminated sequence of 0 or more key/value pairs
 * from the stream:
 * <ul>
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is
 * deserialized using the corresponding value object and added to this
 * <code>DragSource</code>.
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceMotionListenerK</code>, a
 * <code>DragSourceMotionListener</code> is deserialized using the
 * corresponding value object and added to this <code>DragSource</code>.
 * <li>Otherwise, the key/value pair is skipped.
 * </ul>
 *
 * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
 * @since 1.4
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException {
    s.defaultReadObject();

    // 'flavorMap' was written explicitly
    flavorMap = (FlavorMap)s.readObject();

    // Implementation assumes 'flavorMap' is never null.
    if (flavorMap == null) {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
        String key = ((String)keyOrNull).intern();

        if (dragSourceListenerK == key) {
            addDragSourceListener((DragSourceListener)(s.readObject()));
        } else if (dragSourceMotionListenerK == key) {
            addDragSourceMotionListener(
                (DragSourceMotionListener)(s.readObject()));
        } else {
            // skip value for unrecognized key
            s.readObject();
        }
    }
}
 
源代码19 项目: openjdk-jdk8u-backup   文件: DragSource.java
/**
 * Start a drag, given the <code>DragGestureEvent</code>
 * that initiated the drag, the initial
 * <code>Cursor</code> to use,
 * the <code>Image</code> to drag,
 * the offset of the <code>Image</code> origin
 * from the hotspot of the <code>Cursor</code> at
 * the instant of the trigger,
 * the <code>Transferable</code> subject data
 * of the drag, the <code>DragSourceListener</code>,
 * and the <code>FlavorMap</code>.
 * <P>
 * @param trigger        the <code>DragGestureEvent</code> that initiated the drag
 * @param dragCursor     the initial {@code Cursor} for this drag operation
 *                       or {@code null} for the default cursor handling;
 *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
 *                       for more details on the cursor handling mechanism during drag and drop
 * @param dragImage      the image to drag or {@code null}
 * @param imageOffset    the offset of the <code>Image</code> origin from the hotspot
 *                       of the <code>Cursor</code> at the instant of the trigger
 * @param transferable   the subject data of the drag
 * @param dsl            the <code>DragSourceListener</code>
 * @param flavorMap      the <code>FlavorMap</code> to use, or <code>null</code>
 * <P>
 * @throws java.awt.dnd.InvalidDnDOperationException
 *    if the Drag and Drop
 *    system is unable to initiate a drag operation, or if the user
 *    attempts to start a drag while an existing drag operation
 *    is still executing
 */

public void startDrag(DragGestureEvent   trigger,
                      Cursor             dragCursor,
                      Image              dragImage,
                      Point              imageOffset,
                      Transferable       transferable,
                      DragSourceListener dsl,
                      FlavorMap          flavorMap) throws InvalidDnDOperationException {

    SunDragSourceContextPeer.setDragDropInProgress(true);

    try {
        if (flavorMap != null) this.flavorMap = flavorMap;

        DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);

        DragSourceContext     dsc = createDragSourceContext(dscp,
                                                            trigger,
                                                            dragCursor,
                                                            dragImage,
                                                            imageOffset,
                                                            transferable,
                                                            dsl
                                                            );

        if (dsc == null) {
            throw new InvalidDnDOperationException();
        }

        dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
    } catch (RuntimeException e) {
        SunDragSourceContextPeer.setDragDropInProgress(false);
        throw e;
    }
}
 
源代码20 项目: openjdk-jdk8u-backup   文件: DragSource.java
/**
 * Deserializes this <code>DragSource</code>. This method first performs
 * default deserialization. Next, this object's <code>FlavorMap</code> is
 * deserialized by using the next object in the stream.
 * If the resulting <code>FlavorMap</code> is <code>null</code>, this
 * object's <code>FlavorMap</code> is set to the default FlavorMap for
 * this thread's <code>ClassLoader</code>.
 * Next, this object's listeners are deserialized by reading a
 * <code>null</code>-terminated sequence of 0 or more key/value pairs
 * from the stream:
 * <ul>
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is
 * deserialized using the corresponding value object and added to this
 * <code>DragSource</code>.
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceMotionListenerK</code>, a
 * <code>DragSourceMotionListener</code> is deserialized using the
 * corresponding value object and added to this <code>DragSource</code>.
 * <li>Otherwise, the key/value pair is skipped.
 * </ul>
 *
 * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
 * @since 1.4
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException {
    s.defaultReadObject();

    // 'flavorMap' was written explicitly
    flavorMap = (FlavorMap)s.readObject();

    // Implementation assumes 'flavorMap' is never null.
    if (flavorMap == null) {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
        String key = ((String)keyOrNull).intern();

        if (dragSourceListenerK == key) {
            addDragSourceListener((DragSourceListener)(s.readObject()));
        } else if (dragSourceMotionListenerK == key) {
            addDragSourceMotionListener(
                (DragSourceMotionListener)(s.readObject()));
        } else {
            // skip value for unrecognized key
            s.readObject();
        }
    }
}
 
源代码21 项目: Bytecoder   文件: DropTarget.java
/**
 * Creates a new DropTarget given the {@code Component}
 * to associate itself with, an {@code int} representing
 * the default acceptable action(s) to
 * support, a {@code DropTargetListener}
 * to handle event processing, a {@code boolean} indicating
 * if the {@code DropTarget} is currently accepting drops, and
 * a {@code FlavorMap} to use (or null for the default {@code FlavorMap}).
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c         The {@code Component} with which this {@code DropTarget} is associated
 * @param ops       The default acceptable actions for this {@code DropTarget}
 * @param dtl       The {@code DropTargetListener} for this {@code DropTarget}
 * @param act       Is the {@code DropTarget} accepting drops.
 * @param fm        The {@code FlavorMap} to use, or null for the default {@code FlavorMap}
 * @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();
    }
}
 
源代码22 项目: Bytecoder   文件: DragSource.java
/**
 * Deserializes this {@code DragSource}. This method first performs
 * default deserialization. Next, this object's {@code FlavorMap} is
 * deserialized by using the next object in the stream.
 * If the resulting {@code FlavorMap} is {@code null}, this
 * object's {@code FlavorMap} is set to the default FlavorMap for
 * this thread's {@code ClassLoader}.
 * Next, this object's listeners are deserialized by reading a
 * {@code null}-terminated sequence of 0 or more key/value pairs
 * from the stream:
 * <ul>
 * <li>If a key object is a {@code String} equal to
 * {@code dragSourceListenerK}, a {@code DragSourceListener} is
 * deserialized using the corresponding value object and added to this
 * {@code DragSource}.
 * <li>If a key object is a {@code String} equal to
 * {@code dragSourceMotionListenerK}, a
 * {@code DragSourceMotionListener} is deserialized using the
 * corresponding value object and added to this {@code DragSource}.
 * <li>Otherwise, the key/value pair is skipped.
 * </ul>
 *
 * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
 * @since 1.4
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException {
    s.defaultReadObject();

    // 'flavorMap' was written explicitly
    flavorMap = (FlavorMap)s.readObject();

    // Implementation assumes 'flavorMap' is never null.
    if (flavorMap == null) {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
        String key = ((String)keyOrNull).intern();

        if (dragSourceListenerK == key) {
            addDragSourceListener((DragSourceListener)(s.readObject()));
        } else if (dragSourceMotionListenerK == key) {
            addDragSourceMotionListener(
                (DragSourceMotionListener)(s.readObject()));
        } else {
            // skip value for unrecognized key
            s.readObject();
        }
    }
}
 
源代码23 项目: Bytecoder   文件: DesktopDatatransferServiceImpl.java
@Override
public FlavorMap getFlavorMap(Supplier<FlavorMap> supplier) {
    AppContext context = AppContext.getAppContext();
    FlavorMap fm = (FlavorMap) context.get(FLAVOR_MAP_KEY);
    if (fm == null) {
        fm = supplier.get();
        context.put(FLAVOR_MAP_KEY, fm);
    }
    return fm;
}
 
源代码24 项目: openjdk-8-source   文件: 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();
    }
}
 
源代码25 项目: 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();
    }
}
 
源代码26 项目: openjdk-jdk9   文件: DragSource.java
/**
 * Deserializes this {@code DragSource}. This method first performs
 * default deserialization. Next, this object's {@code FlavorMap} is
 * deserialized by using the next object in the stream.
 * If the resulting {@code FlavorMap} is {@code null}, this
 * object's {@code FlavorMap} is set to the default FlavorMap for
 * this thread's {@code ClassLoader}.
 * Next, this object's listeners are deserialized by reading a
 * {@code null}-terminated sequence of 0 or more key/value pairs
 * from the stream:
 * <ul>
 * <li>If a key object is a {@code String} equal to
 * {@code dragSourceListenerK}, a {@code DragSourceListener} is
 * deserialized using the corresponding value object and added to this
 * {@code DragSource}.
 * <li>If a key object is a {@code String} equal to
 * {@code dragSourceMotionListenerK}, a
 * {@code DragSourceMotionListener} is deserialized using the
 * corresponding value object and added to this {@code DragSource}.
 * <li>Otherwise, the key/value pair is skipped.
 * </ul>
 *
 * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
 * @since 1.4
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException {
    s.defaultReadObject();

    // 'flavorMap' was written explicitly
    flavorMap = (FlavorMap)s.readObject();

    // Implementation assumes 'flavorMap' is never null.
    if (flavorMap == null) {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
        String key = ((String)keyOrNull).intern();

        if (dragSourceListenerK == key) {
            addDragSourceListener((DragSourceListener)(s.readObject()));
        } else if (dragSourceMotionListenerK == key) {
            addDragSourceMotionListener(
                (DragSourceMotionListener)(s.readObject()));
        } else {
            // skip value for unrecognized key
            s.readObject();
        }
    }
}
 
@Override
public FlavorMap getFlavorMap(Supplier<FlavorMap> supplier) {
    AppContext context = AppContext.getAppContext();
    FlavorMap fm = (FlavorMap) context.get(FLAVOR_MAP_KEY);
    if (fm == null) {
        fm = supplier.get();
        context.put(FLAVOR_MAP_KEY, fm);
    }
    return fm;
}
 
源代码28 项目: openjdk-jdk9   文件: DataFlavorUtil.java
@Override
public FlavorMap getFlavorMap(Supplier<FlavorMap> supplier) {
    FlavorMap map = flavorMap;
    if (map == null) {
        synchronized (this) {
            map = flavorMap;
            if (map == null) {
                flavorMap = map = supplier.get();
            }
        }
    }
    return map;
}
 
源代码29 项目: jdk8u_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();
    }
}
 
源代码30 项目: openjdk-8   文件: 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();
    }
}
 
 类所在包
 同包方法