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

RFE: stop triple clicking tree nodes to edit them from also toggling them

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Unresolved
    • P5
    • None
    • 6u10
    • client-libs

    Description

      J2SE Version (please include all output from java -version flag):
      java version "1.6.0_06"
      Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
      Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)

      Does this problem occur on J2SE 5.0.x or 6.0? Yes / No (pick one)
      Yes

      Operating System Configuration Information (be specific):
      Microsoft Windows XP [Version 5.1.2600]

      Bug Description:
      RFE: stop triple clicking tree nodes to edit them from also toggling them

      When running the code below:
      * Single Click will select the node (as expected)
      * Double Clicking will toggle the node (as expected)
      * Triple Clicking will edit the node (as expected), however it will also toggle the node (hence the problem)

      Uncommenting the commented out code will show the expected behavior for all three click types.

      import static javax.swing.JFrame.*;
      import static javax.swing.SwingUtilities.*;
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.tree.*;

      public class Test {
      // private static Timer timer;
           
        public static void main(String[] args) {
          final JTree tree = new JTree();
          tree.setEditable(true);
         
      // tree.setToggleClickCount(0);
      // tree.addMouseListener(new MouseAdapter() {
      // public void mousePressed(MouseEvent anEvent) {
      // if (isLeftMouseButton(anEvent)) {
      // switch (anEvent.getClickCount()) {
      // case 2: {
      // Object multiClickInterval = Toolkit.getDefaultToolkit().getDesktopProperty(
      // "awt.multiClickInterval");
      // timer = new Timer(multiClickInterval instanceof Integer ? (Integer)multiClickInterval
      // : 500, new ActionListener() {
      // public void actionPerformed(ActionEvent e) {
      // timer = null;
      // TreePath treePath = tree.getSelectionPath();
      // if (treePath != null) {
      // if (tree.isExpanded(treePath)) {
      // tree.collapsePath(treePath);
      // return;
      // }
      // tree.expandPath(treePath);
      // }
      // }
      // });
      // timer.setRepeats(false);
      // timer.start();
      // return;
      // }
      // case 3: {
      // if (timer != null) {
      // timer.stop();
      // timer = null;
      // }
      // return;
      // }
      // }
      // }
      // }
      // });
         
          JFrame frame = new JFrame();
          frame.setBounds(100, 100, 500, 500);
          frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
          frame.add(tree);
          frame.setVisible(true);
        }
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Imported:
              Indexed: