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


Java DragSource.createDefaultDragGestureRecognizer方法代码示例

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


在下文中一共展示了DragSource.createDefaultDragGestureRecognizer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: DragManager

import java.awt.dnd.DragSource; //导入方法依赖的package包/类
/** Creates a new instance of SplashDnDSupport */
DragManager(JComponent component) {
    this.component = component;
    dSource =  new DragSource();
    dRecognizer = dSource.createDefaultDragGestureRecognizer(this.component,DnDConstants.ACTION_MOVE,this);
    dTarget = new DropTarget(this.component,DnDConstants.ACTION_MOVE,this);
    component.addMouseMotionListener(this);
    oCursor = component.getCursor();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:DragManager.java

示例3: 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

示例4: installDragGestureHandler

import java.awt.dnd.DragSource; //导入方法依赖的package包/类
/**
 * 
 */
protected void installDragGestureHandler() {
  DragGestureListener dragGestureListener = new DragGestureListener() {
    public void dragGestureRecognized(DragGestureEvent e) {
      if (graphComponent.isDragEnabled() && first != null) {
        final TransferHandler th = graphComponent.getTransferHandler();

        if (th instanceof mxGraphTransferHandler) {
          final mxGraphTransferable t = (mxGraphTransferable) ((mxGraphTransferHandler) th)
              .createTransferable(graphComponent);

          if (t != null) {
            e.startDrag(null, mxSwingConstants.EMPTY_IMAGE, new Point(), t,
                new DragSourceAdapter() {

                  /**
                   * 
                   */
                  public void dragDropEnd(DragSourceDropEvent dsde) {
                    ((mxGraphTransferHandler) th).exportDone(graphComponent, t,
                        TransferHandler.NONE);
                    first = null;
                  }
                });
          }
        }
      }
    }
  };

  DragSource dragSource = new DragSource();
  dragSource.createDefaultDragGestureRecognizer(graphComponent.getGraphControl(),
      (isCloneEnabled()) ? DnDConstants.ACTION_COPY_OR_MOVE : DnDConstants.ACTION_MOVE,
      dragGestureListener);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:38,代码来源:mxGraphHandler.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: 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

示例7: 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

示例8: 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

示例9: TreeTransferHandler

import java.awt.dnd.DragSource; //导入方法依赖的package包/类
protected TreeTransferHandler(JTree tree, JTreeDragController controller, int action, boolean drawIcon) {
	this.tree = tree;
	this.controller = controller;
	drawImage = drawIcon;
	dragSource = new DragSource();
	dragSource.createDefaultDragGestureRecognizer(tree, action, this);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:8,代码来源:JTreeUtil.java

示例10: initRepositoryViewer

import java.awt.dnd.DragSource; //导入方法依赖的package包/类
private void initRepositoryViewer(){
	this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	DragSource ds = new DragSource();
	ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY,
			new RepositoryViewerDragGestureListener());
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:7,代码来源:RepositoryViewer.java

示例11: installDragGestureHandler

import java.awt.dnd.DragSource; //导入方法依赖的package包/类
/**
 * 
 */
protected void installDragGestureHandler()
{
	DragGestureListener dragGestureListener = new DragGestureListener()
	{
		public void dragGestureRecognized(DragGestureEvent e)
		{
			if (graphComponent.isDragEnabled() && first != null)
			{
				final TransferHandler th = graphComponent
						.getTransferHandler();

				if (th instanceof mxGraphTransferHandler)
				{
					final mxGraphTransferable t = (mxGraphTransferable) ((mxGraphTransferHandler) th)
							.createTransferable(graphComponent);

					if (t != null)
					{
						e.startDrag(null, mxSwingConstants.EMPTY_IMAGE,
								new Point(), t, new DragSourceAdapter()
								{

									/**
									 * 
									 */
									public void dragDropEnd(
											DragSourceDropEvent dsde)
									{
										((mxGraphTransferHandler) th)
												.exportDone(
														graphComponent,
														t,
														TransferHandler.NONE);
										first = null;
									}
								});
					}
				}
			}
		}
	};

	DragSource dragSource = new DragSource();
	dragSource.createDefaultDragGestureRecognizer(graphComponent
			.getGraphControl(),
			(isCloneEnabled()) ? DnDConstants.ACTION_COPY_OR_MOVE
					: DnDConstants.ACTION_MOVE, dragGestureListener);
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:52,代码来源:mxGraphHandler.java


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