Example usage for java.awt.dnd DropTargetDragEvent acceptDrag

List of usage examples for java.awt.dnd DropTargetDragEvent acceptDrag

Introduction

In this page you can find the example usage for java.awt.dnd DropTargetDragEvent acceptDrag.

Prototype

public void acceptDrag(int dragOperation) 

Source Link

Document

Accepts the drag.

Usage

From source file:ColorSink.java

public void dragEnter(DropTargetDragEvent e) {
    if (e.isDataFlavorSupported(TransferableColor.colorFlavor)
            || e.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
        e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
        this.setBorder(dropBorder);
    }/*from w ww .  j a  v a 2  s.  c  o m*/
}

From source file:DNDList.java

/**
 * is invoked when you are dragging over the DropSite
 * //w  ww . j  a v  a  2  s.c  o  m
 */

public void dragEnter(DropTargetDragEvent event) {

    // debug messages for diagnostics
    System.out.println("dragEnter");
    event.acceptDrag(DnDConstants.ACTION_MOVE);
}

From source file:de.tor.tribes.ui.windows.AbstractDSWorkbenchFrame.java

@Override
public void dragEnter(DropTargetDragEvent dtde) {
    if (dtde.isDataFlavorSupported(VillageTransferable.villageDataFlavor)
            || dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) {
        dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
    }/*from  w  w  w .  j ava 2 s  .c o m*/
}

From source file:com.mirth.connect.client.ui.editors.JavaScriptEditorDialog.java

public void dragEnter(DropTargetDragEvent dtde) {
    try {/*ww  w  .  j  av  a  2  s .  co m*/
        Transferable tr = dtde.getTransferable();
        if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {

            dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);

            java.util.List fileList = (java.util.List) tr.getTransferData(DataFlavor.javaFileListFlavor);
            Iterator iterator = fileList.iterator();
            while (iterator.hasNext()) {
                iterator.next();
            }
        } else {
            dtde.rejectDrag();
        }
    } catch (Exception e) {
        dtde.rejectDrag();
    }
}

From source file:TreeDragTest.java

public void dragEnter(DropTargetDragEvent dtde) {
    TreeNode node = getNodeForEvent(dtde);
    if (node.isLeaf()) {
        dtde.rejectDrag();/*w ww  . j av a 2 s. c  o m*/
    } else {
        // start by supporting move operations
        //dtde.acceptDrag(DnDConstants.ACTION_MOVE);
        dtde.acceptDrag(dtde.getDropAction());
    }
}

From source file:TreeDragTest.java

public void dragOver(DropTargetDragEvent dtde) {
    TreeNode node = getNodeForEvent(dtde);
    if (node.isLeaf()) {
        dtde.rejectDrag();//from w w w .j  ava 2  s.  co  m
    } else {
        // start by supporting move operations
        //dtde.acceptDrag(DnDConstants.ACTION_MOVE);
        dtde.acceptDrag(dtde.getDropAction());
    }
}

From source file:org.jas.dnd.MultiLayerDropTargetListener.java

@Override
public void dragOver(DropTargetDragEvent dtde) {
    initializeTransferable(dtde.getTransferable(), false);
    getDragAction().setLocation(dtde.getLocation());
    if (getDragAction().validate(dtde.getLocation())) {
        dtde.acceptDrag(DnDConstants.ACTION_COPY);
    } else {//  ww  w.  ja  va 2s .co  m
        dtde.rejectDrag();
    }
}

From source file:com.mirth.connect.client.ui.TemplatePanel.java

public void dragEnter(DropTargetDragEvent dtde) {
    try {//  w ww . jav  a  2  s  . c o m
        Transferable tr = dtde.getTransferable();

        if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
            dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
            List<File> fileList = (List<File>) tr.getTransferData(DataFlavor.javaFileListFlavor);
            Iterator<File> iterator = fileList.iterator();

            while (iterator.hasNext()) {
                iterator.next();
            }
        } else {
            dtde.rejectDrag();
        }
    } catch (Exception e) {
        dtde.rejectDrag();
    }
}

From source file:com.mirth.connect.client.ui.EditMessageDialog.java

public void dragEnter(DropTargetDragEvent dtde) {
    try {// ww  w .j  a va 2 s .  c  o m
        Transferable tr = dtde.getTransferable();
        if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {

            dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);

            List<File> fileList = (List<File>) tr.getTransferData(DataFlavor.javaFileListFlavor);
            Iterator<File> iterator = fileList.iterator();
            while (iterator.hasNext()) {
                iterator.next();
            }
        } else {
            dtde.rejectDrag();
        }
    } catch (Exception e) {
        dtde.rejectDrag();
    }
}

From source file:ScribbleDragAndDrop.java

/**
 * This method is invoked when the user first drags something over us. If we
 * understand the data type being dragged, then call acceptDrag() to tell
 * the system that we're receptive. Also, we change our border as a "drag
 * under" effect to signal that we can accept the drop.
 */// w w w . j  a  v a 2 s .  co m
public void dragEnter(DropTargetDragEvent e) {
    if (e.isDataFlavorSupported(Scribble.scribbleDataFlavor)
            || e.isDataFlavorSupported(DataFlavor.stringFlavor)) {
        e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
        this.setBorder(dropBorder);
    }
}