Drag And Drop

DragAnd Drop (DnD) is available for many Components.

DragAndDrop Example: (Run Applet)

import javax.swing.*;

public class DragAndDropDemo extends JApplet
{
    @Override
    public void init()
    {
        this.setContentPane(new View());
    }

    public class View extends JPanel
    {
        private final JTextArea textArea = new JTextArea("Welcome to DkIT");
        private final JTextField textField = new JTextField(20);

        public View()
        {
            super();
            add(this.textArea); // add the scrollable area
            add(this.textField);

            this.textArea.setDragEnabled(true);
            this.textField.setDragEnabled(true);
        }
    }
}
 
<div align="center"><a href="../versionC/index.html" title="DKIT Lecture notes homepage for Derek O&#39; Reilly, Dundalk Institute of Technology (DKIT), Dundalk, County Louth, Ireland. Copyright Derek O&#39; Reilly, DKIT." target="_parent" style='font-size:0;color:white;background-color:white'>&nbsp;</a></div>