当前位置: 首页>>代码示例>>Java>>正文


Java Component.setDropTarget方法代码示例

本文整理汇总了Java中java.awt.Component.setDropTarget方法的典型用法代码示例。如果您正苦于以下问题:Java Component.setDropTarget方法的具体用法?Java Component.setDropTarget怎么用?Java Component.setDropTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Component的用法示例。


在下文中一共展示了Component.setDropTarget方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setComponent

import java.awt.Component; //导入方法依赖的package包/类
/**
 * 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();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:DropTarget.java

示例2: DropTarget

import java.awt.Component; //导入方法依赖的package包/类
/**
 * 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();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:49,代码来源:DropTarget.java

示例3: setComponent

import java.awt.Component; //导入方法依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:42,代码来源:DropTarget.java

示例4: DropTarget

import java.awt.Component; //导入方法依赖的package包/类
/**
 * 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();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:49,代码来源:DropTarget.java


注:本文中的java.awt.Component.setDropTarget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。