Example usage for java.awt.dnd DropTarget DropTarget

List of usage examples for java.awt.dnd DropTarget DropTarget

Introduction

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

Prototype

public DropTarget(Component c, DropTargetListener dtl) throws HeadlessException 

Source Link

Document

Creates a DropTarget given the Component to associate itself with, and the DropTargetListener to handle event processing.

Usage

From source file:Main.java

public Main() {
    super("Drop Test");
    setSize(300, 300);/*from w  w w  . j  a  v  a2s  . c  o m*/
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    add(new JLabel("Drop a list from your file chooser here:"), BorderLayout.NORTH);
    ta.setBackground(Color.white);
    getContentPane().add(ta, BorderLayout.CENTER);

    dt = new DropTarget(ta, this);
    setVisible(true);
}

From source file:DropTest.java

public DropTest() {
    super("Drop Test");
    setSize(300, 300);//  w  w w.  j  av  a2s .co  m
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    add(new JLabel("Drop a list from your file chooser here:"), BorderLayout.NORTH);
    ta.setBackground(Color.white);
    getContentPane().add(ta, BorderLayout.CENTER);

    dt = new DropTarget(ta, this);
    setVisible(true);
}

From source file:Main.java

public Main() {
    super("Drop Test");
    setSize(300, 300);//from   w  w w .  ja v  a2s .c o  m
    getContentPane().add(new JLabel("Drop something here:"), BorderLayout.NORTH);

    ta.setBackground(Color.white);
    getContentPane().add(ta, BorderLayout.CENTER);
    dt = new DropTarget(ta, this);
    setVisible(true);
}

From source file:DropTest.java

public DropTest() {
    super("Drop Test");
    setSize(300, 300);/*from  ww  w  .jav  a 2s . com*/

    getContentPane().add(new JLabel("Drop a list from your file chooser here:"), BorderLayout.NORTH);
    ta = new JTextArea();
    ta.setBackground(Color.white);
    getContentPane().add(ta, BorderLayout.CENTER);

    // Set up our text area to recieve drops...
    // This class will handle drop events
    dt = new DropTarget(ta, this);
    setVisible(true);
}

From source file:DropTest2.java

public DropTest2() {
    super("Drop Test");
    setSize(300, 300);/*from www.  j  a  v a 2 s. c om*/

    getContentPane().add(new JLabel("Drop a list from your file chooser here:"), BorderLayout.NORTH);
    ta = new JTextArea();
    ta.setBackground(Color.white);
    getContentPane().add(ta, BorderLayout.CENTER);

    // Set up our text area to recieve drops...
    // This class will handle drop events
    dt = new DropTarget(ta, this);
    setVisible(true);
}

From source file:ColorSink.java

/** Create a new ColorSink object */
public ColorSink() {
    // Listen for double clicks.  Use them to trigger a paste action.
    addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                pastecolor();//from  w  w  w  .j a  v a 2  s. c om
                e.consume();
            }
        }
    });

    // We have to create a DropTarget object to support Drag-and-Drop
    // It will listen for drops on top of us, and notify our DropTargetListener
    // methods when drag-and-drop related events occur.
    setDropTarget(new DropTarget(this, this));
}

From source file:DNDList.java

/**
 * constructor - initializes the DropTarget and DragSource.
 *///from w  ww  . j  a v a2  s.c om

public DNDList(ListModel dataModel) {
    super(dataModel);
    dropTarget = new DropTarget(this, this);
    dragSource = new DragSource();
    dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this);
}

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

private void initialize(String script) {
    this.parent = PlatformUI.MIRTH_FRAME;
    initComponents();//from w  ww .  j a va  2s  . c o m
    scriptContent.setSaveEnabled(false);
    setSavedScript(script);
    scriptContent.setCaretPosition(0);

    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

    this.addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            cancelButtonActionPerformed(null);
        }
    });

    pack();
    new DropTarget(scriptContent, this);
    Dimension dlgSize = getPreferredSize();
    Dimension frmSize = parent.getSize();
    Point loc = parent.getLocation();

    if ((frmSize.width == 0 && frmSize.height == 0) || (loc.x == 0 && loc.y == 0)) {
        setLocationRelativeTo(null);
    } else {
        setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
    }

    setVisible(true);
}

From source file:TreeTester.java

public DndTree() {
    DragSource dragSource = DragSource.getDefaultDragSource();
    dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE,
            new TreeDragGestureListener());
    DropTarget dropTarget = new DropTarget(this, new TreeDropTargetListener());
}

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

public EditMessageDialog() {
    super(PlatformUI.MIRTH_FRAME);
    this.parent = PlatformUI.MIRTH_FRAME;
    initComponents();/*w w  w .j  ava 2s .  c  o m*/
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setModalityType(ModalityType.DOCUMENT_MODAL);
    pack();
    new DropTarget(messageContent, this);
}