Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4273712

Triple click on editable JTree causes dragGestureRecognized to be called

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.0
    • client-libs
    • 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)
      ======================================================================

            dassunw Das Das (Inactive)
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: