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


Java DragSource.getDefaultDragSource方法代码示例

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


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

示例1: main

import java.awt.dnd.DragSource; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Frame sourceFrame = createFrame("Source Frame", 0, 0);
    Frame targetFrame = createFrame("Target Frame", 250, 250);

    DragSource defaultDragSource
            = DragSource.getDefaultDragSource();
    defaultDragSource.createDefaultDragGestureRecognizer(sourceFrame,
            DnDConstants.ACTION_COPY_OR_MOVE,
            new TestDragGestureListener());
    new DropTarget(targetFrame, DnDConstants.ACTION_COPY_OR_MOVE,
            new TestDropTargetListener(targetFrame));

    Robot robot = new Robot();
    robot.setAutoDelay(50);

    sourceFrame.toFront();
    robot.waitForIdle();

    Point point = getCenterPoint(sourceFrame);
    robot.mouseMove(point.x, point.y);
    robot.waitForIdle();

    mouseDragAndDrop(robot, point, getCenterPoint(targetFrame));

    long time = System.currentTimeMillis() + 200;

    while (!passed) {
        if (time < System.currentTimeMillis()) {
            sourceFrame.dispose();
            targetFrame.dispose();
            throw new RuntimeException("Mouse clicked event is lost!");
        }
        Thread.sleep(10);
    }
    sourceFrame.dispose();
    targetFrame.dispose();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:MissingEventsOnModalDialogTest.java

示例2: IndexedDragSource

import java.awt.dnd.DragSource; //导入方法依赖的package包/类
/** Creates drag source with asociated list where drag
* will take place.
* Also creates the default gesture and asociates this with
* given component */
IndexedDragSource(JList comp) {
    this.comp = comp;

    // initialize gesture
    DragSource ds = DragSource.getDefaultDragSource();
    ds.createDefaultDragGestureRecognizer(comp, DnDConstants.ACTION_MOVE, this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:IndexedCustomizer.java

示例3: run

import java.awt.dnd.DragSource; //导入方法依赖的package包/类
/** Performs DnD pre-heat.
 */
@Override
public void run() {
    if (!GraphicsEnvironment.isHeadless()) {
        DragSource.getDefaultDragSource();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:DnDWarmUpTask.java

示例4: SourcePanel

import java.awt.dnd.DragSource; //导入方法依赖的package包/类
public SourcePanel () {
    setPreferredSize(new Dimension(200, 200));
    DragSource defaultDragSource =
            DragSource.getDefaultDragSource();
    defaultDragSource.createDefaultDragGestureRecognizer(this,
            DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
    setBackground(Color.RED);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:SourcePanel.java

示例5: SourcePanel

import java.awt.dnd.DragSource; //导入方法依赖的package包/类
public SourcePanel() {
    setPreferredSize(new Dimension(200, 200));
    DragSource defaultDragSource =
            DragSource.getDefaultDragSource();
    defaultDragSource.createDefaultDragGestureRecognizer(this,
            DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener);
    setBackground(Color.RED);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:SourcePanel.java

示例6: DragSourceButton

import java.awt.dnd.DragSource; //导入方法依赖的package包/类
public DragSourceButton(String str) {
    super(str);

    DragSource ds = DragSource.getDefaultDragSource();
    ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY,
            this);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:RemoveDropTargetCrashTest.java

示例7: runTest

import java.awt.dnd.DragSource; //导入方法依赖的package包/类
private static void runTest() throws Exception {
    Frame sourceFrame = createFrame("Source Frame", 100, 100);
    Frame targetFrame = createFrame("Target Frame", 350, 350);

    DragSource defaultDragSource
            = DragSource.getDefaultDragSource();
    defaultDragSource.createDefaultDragGestureRecognizer(sourceFrame,
            DnDConstants.ACTION_COPY_OR_MOVE,
            new TestDragGestureListener());
    new DropTarget(targetFrame, DnDConstants.ACTION_COPY_OR_MOVE,
            new TestDropTargetListener(targetFrame));

    Robot robot = new Robot();
    robot.setAutoDelay(50);

    sourceFrame.toFront();
    robot.waitForIdle();

    Point point = getCenterPoint(sourceFrame);
    robot.mouseMove(point.x, point.y);
    robot.waitForIdle();

    mouseDragAndDrop(robot, point, getCenterPoint(targetFrame));

    long time = System.currentTimeMillis() + 1000;

    while (!passed) {
        if (time < System.currentTimeMillis()) {
            sourceFrame.dispose();
            targetFrame.dispose();
            throw new RuntimeException("Mouse clicked event is lost!");
        }
        Thread.sleep(10);
    }
    sourceFrame.dispose();
    targetFrame.dispose();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:MissingEventsOnModalDialogTest.java

示例8: SwingDragGestureRecognizer

import java.awt.dnd.DragSource; //导入方法依赖的package包/类
SwingDragGestureRecognizer() {
	super(DragSource.getDefaultDragSource(), null, NONE, null);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:4,代码来源:AbstractPatchedTransferHandler.java

示例9: FreeColDragGestureRecognizer

import java.awt.dnd.DragSource; //导入方法依赖的package包/类
FreeColDragGestureRecognizer(DragGestureListener dgl) {
    super(DragSource.getDefaultDragSource(), null, NONE, dgl);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:4,代码来源:DefaultTransferHandler.java


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