Java Example Program / Sample Source Code
import java.awt.BorderLayout;
import java.awt.List;
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 java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
public class DragGestureRecognizerExample extends JFrame implements
DragGestureListener {
DragSource dataSource;
List list;
public DragGestureRecognizerExample() {
super("DragGestureRecognizerExample");
setSize(200, 150);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
list = new List(2);
list.add("Java");
list.add("Jsp");
list.add("Servlet");
getContentPane().add(new JScrollPane(list), BorderLayout.CENTER);
dataSource = new DragSource();
DragGestureRecognizer dgr = dataSource
.createDefaultDragGestureRecognizer(list,
DnDConstants.ACTION_COPY, this);
setVisible(true);
}
public void dragGestureRecognized(DragGestureEvent dge) {
System.out.println("DragGestureEvent Fired");
}
public static void main(String args[]) {
new DragGestureRecognizerExample();
}
} |
|
|