當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。