-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0
-
beta2
-
generic
-
generic
Name: rlT66838 Date: 09/20/99
/*If you have an editable JTree which is set up as a
DragGestureListener and DragSourceListener, then if you
triple click on a node to put it into edit mode, it also
ends up calling dragGestureRecognized to start a drag
operation.
Compile and run the test program.
Triple click on a tree node, and note that it
puts it into edit mode, and it gets in to the
dragGestureRecognized method. This happens on Solaris
and Windows. */
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.dnd.*;
import java.awt.event.*;
import java.awt.datatransfer.StringSelection;
public class TreeTest extends JPanel implements DragGestureListener, DragSourceListener
{
public void dragGestureRecognized(DragGestureEvent e)
{
System.out.println("dragGestureRecognized");
e.startDrag(DragSource.DefaultCopyDrop, new StringSelection("blah"), this);
}
public TreeTest()
{
super(new BorderLayout());
JTree tree = new JTree();
tree.setEditable(true);
add("Center", tree);
DragSource dragSource = DragSource.getDefaultDragSource();
dragSource.createDefaultDragGestureRecognizer(tree, DnDConstants.ACTION_MOVE, this);
}
public static void main(String[] args)
{
JFrame frame = new JFrame("JTree Test");
frame.getContentPane().add("Center", new TreeTest());
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.pack();
frame.setVisible(true);
}
public void dragDropEnd(DragSourceDropEvent e) {}
public void dragEnter(DragSourceDragEvent e) {}
public void dragExit(DragSourceEvent e) {}
public void dragOver(DragSourceDragEvent e) {}
public void dropActionChanged(DragSourceDragEvent e) {}
}
(Review ID: 95476)
======================================================================
- relates to
-
JDK-4396746 DnD auto-starts [dragGestureRecognized() called] in JTree when the tree scrolls
-
- Resolved
-