Source Code : Detect a drag initiating gesture in your application
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Detect a drag initiating gesture in your application
import java.awt.BorderLayout;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.DragGestureListener;
import java.awt.dnd.DragGestureRecognizer;
import java.awt.dnd.DragSource;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
public class Main extends JFrame implements DragGestureListener {
String[] items = { "Java", "C", "C++", "Lisp", "Perl", "Python" };
DragSource ds = new DragSource();
JList jl = new JList(items);
public Main() {
setSize(200, 150);
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);
}
public void dragGestureRecognized(DragGestureEvent dge) {
System.out.println("Drag Gesture Recognized!");
}
public static void main(String args[]) {
new Main();
}
}
Thank with us