Example usage for java.awt.dnd DnDConstants ACTION_COPY_OR_MOVE

List of usage examples for java.awt.dnd DnDConstants ACTION_COPY_OR_MOVE

Introduction

In this page you can find the example usage for java.awt.dnd DnDConstants ACTION_COPY_OR_MOVE.

Prototype

int ACTION_COPY_OR_MOVE

To view the source code for java.awt.dnd DnDConstants ACTION_COPY_OR_MOVE.

Click Source Link

Document

An int representing a "copy" or "move" action.

Usage

From source file:Main.java

public DraggableComponent() {
    dragSource = new DragSource();
    dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, this);
}

From source file:PanelDropTarget.java

public PanelDropTarget(JPanel pane) {
    this.pane = pane;

    // Create the DropTarget and register
    // it with the JPanel.
    dropTarget = new DropTarget(pane, DnDConstants.ACTION_COPY_OR_MOVE, this, true, null);
}

From source file:EditorDropTarget.java

public EditorDropTarget(JEditorPane pane) {
    this.pane = pane;

    // Create the DropTarget and register
    // it with the JEditorPane.
    dropTarget = new DropTarget(pane, DnDConstants.ACTION_COPY_OR_MOVE, this, true, null);
}

From source file:JLabelDragSource.java

public JLabelDragSource(JLabel label) {
    this.label = label;

    // Use the default DragSource
    DragSource dragSource = DragSource.getDefaultDragSource();

    // Create a DragGestureRecognizer and
    // register as the listener
    dragSource.createDefaultDragGestureRecognizer(label, DnDConstants.ACTION_COPY_OR_MOVE, this);
}

From source file:EditorDropTarget2.java

public EditorDropTarget2(JEditorPane pane) {
    this.pane = pane;

    // Create the DropTarget and register
    // it with the JEditorPane.
    dropTarget = new DropTarget(pane, DnDConstants.ACTION_COPY_OR_MOVE, this, true, null);
}

From source file:Main.java

Main(String title) {
    super(title);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    source.setForeground(Color.red);
    getContentPane().add(source, BorderLayout.NORTH);

    target.addActionListener(this);
    getContentPane().add(target, BorderLayout.SOUTH);

    new DropTarget(target, DnDConstants.ACTION_COPY_OR_MOVE, this);

    setSize(205, 100);//from   w  w w. j a va 2s  .  c om

    setVisible(true);
}

From source file:Main.java

public Main(String title) {
    super(title);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    source.setForeground(Color.red);
    getContentPane().add(source, BorderLayout.NORTH);

    target.addActionListener(this);
    getContentPane().add(target, BorderLayout.SOUTH);

    new DropTarget(target, DnDConstants.ACTION_COPY_OR_MOVE, this);

    setSize(205, 100);//from   ww  w  .jav a2s. co m

    setVisible(true);
}

From source file:MainClass.java

MainClass(String title) {
    super(title);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    source.setForeground(Color.red);
    getContentPane().add(source, BorderLayout.NORTH);

    target.addActionListener(this);
    getContentPane().add(target, BorderLayout.SOUTH);

    new DropTarget(target, DnDConstants.ACTION_COPY_OR_MOVE, this);

    setSize(205, 100);//from  w w w . j  a v a  2  s  .  c o m

    setVisible(true);
}

From source file:Main.java

public void drop(DropTargetDropEvent dtde) {
    try {/*from w  w  w  .j  a  v a  2  s  .  co m*/
        Transferable tr = dtde.getTransferable();
        DataFlavor[] flavors = tr.getTransferDataFlavors();
        for (int i = 0; i < flavors.length; i++) {
            if (flavors[i].isFlavorJavaFileListType()) {
                dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
                List list = (List) tr.getTransferData(flavors[i]);
                for (int j = 0; j < list.size(); j++) {
                    ta.append(list.get(j) + "\n");
                }
                dtde.dropComplete(true);
                return;
            } else if (flavors[i].isFlavorSerializedObjectType()) {
                dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
                Object o = tr.getTransferData(flavors[i]);
                ta.append("Object: " + o);
                dtde.dropComplete(true);
                return;
            } else if (flavors[i].isRepresentationClassInputStream()) {
                dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
                ta.read(new InputStreamReader((InputStream) tr.getTransferData(flavors[i])),
                        "from system clipboard");
                dtde.dropComplete(true);
                return;
            }
        }
        dtde.rejectDrop();
    } catch (Exception e) {
        e.printStackTrace();
        dtde.rejectDrop();
    }
}

From source file:EditorDropTarget3.java

public EditorDropTarget3(JEditorPane pane) {
    this.pane = pane;

    // Listen for changes in the enabled property
    pane.addPropertyChangeListener(this);

    // Save the JEditorPane's background color
    backgroundColor = pane.getBackground();

    // Create the DropTarget and register
    // it with the JEditorPane.
    dropTarget = new DropTarget(pane, DnDConstants.ACTION_COPY_OR_MOVE, this, pane.isEnabled(), null);
}