Example usage for java.awt.dnd DnDConstants ACTION_COPY

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

Introduction

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

Prototype

int ACTION_COPY

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

Click Source Link

Document

An int representing a "copy" action.

Usage

From source file:DragGesture.java

public DragGesture() {
    setTitle("Drag Gesture");
    JLabel left = new JLabel("text");
    DragSource ds = new DragSource();
    ds.createDefaultDragGestureRecognizer(left, DnDConstants.ACTION_COPY, this);
    add(left);//from w  ww  . java 2 s  .c o  m
    pack();
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
}

From source file:Main.java

public Main() {
    setSize(200, 150);// w  w w  .j a  v a  2 s. c  o m
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    getContentPane().add(new JScrollPane(jl), BorderLayout.CENTER);

    DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer(jl, DnDConstants.ACTION_COPY, this);
    setVisible(true);
}

From source file:DragGesture.java

public void dragGestureRecognized(DragGestureEvent event) {
    Cursor cursor = null;/*  w  w  w  .  j a va2s .com*/
    if (event.getDragAction() == DnDConstants.ACTION_COPY) {
        cursor = DragSource.DefaultCopyDrop;
    }
    event.startDrag(cursor, this);
}

From source file:Main.java

public Main() {
    super("Gesture Test");
    setSize(200, 150);//w  w w .  ja v  a 2  s  . co m
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    getContentPane().add(new JScrollPane(jl), BorderLayout.CENTER);
    DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer(jl, DnDConstants.ACTION_COPY, this);
    setVisible(true);
}

From source file:Main.java

public Main() {
    super("Gesture Test");
    setSize(200, 150);/*from   w w w  .ja v  a 2  s.  c  o m*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    jl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    getContentPane().add(new JScrollPane(jl), BorderLayout.CENTER);

    DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer(jl, DnDConstants.ACTION_COPY, this);
    setVisible(true);
}

From source file:GestureTest.java

public GestureTest() {
    super("Gesture Test");
    setSize(200, 150);/*from  ww w . j  a v a2s . c om*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    jl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    getContentPane().add(new JScrollPane(jl), BorderLayout.CENTER);

    DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer(jl, DnDConstants.ACTION_COPY, this);
    setVisible(true);
}

From source file:ComplexExample.java

public ComplexExample() {
    JPanel left = new JPanel();
    left.setBackground(Color.red);

    JPanel right = new JPanel();
    right.setBackground(Color.white);

    new MyDropTargetListener(right);

    DragSource ds = new DragSource();
    ds.createDefaultDragGestureRecognizer(left, DnDConstants.ACTION_COPY, this);

    setLayout(new FlowLayout());
    add(left);//from  w w  w  . j ava 2  s .  co  m
    add(right);

    setSize(40, 50);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLocationRelativeTo(null);
    setVisible(true);
}

From source file:GestureTest.java

public GestureTest() {
    super("Gesture Test");
    setSize(200, 150);/*from w  w  w  .  j av a2s . co  m*/
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            System.exit(0);
        }
    });
    jl = new JList(items);
    jl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    getContentPane().add(new JScrollPane(jl), BorderLayout.CENTER);

    ds = new DragSource();
    DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer(jl, DnDConstants.ACTION_COPY, this);
    setVisible(true);
}

From source file:ComplexExample.java

public void dragGestureRecognized(DragGestureEvent event) {
    Cursor cursor = null;//  w  ww . j ava  2 s  . c  om
    JPanel panel = (JPanel) event.getComponent();

    Color color = panel.getBackground();
    if (event.getDragAction() == DnDConstants.ACTION_COPY) {
        cursor = DragSource.DefaultCopyDrop;
    }
    event.startDrag(cursor, new TransferableColor(color));
}

From source file:DragTest.java

public DragTest() {
    super("Drag Test");
    setSize(200, 150);//from   w  ww . j av a2  s.com
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            System.exit(0);
        }
    });
    jl = new JList(items);
    jl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    getContentPane().add(new JScrollPane(jl), BorderLayout.CENTER);

    ds = new DragSource();
    DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer(jl, DnDConstants.ACTION_COPY, this);
    setVisible(true);
}