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

Jtree doesnt refresh tooltip when mouse moved over the nodes with same tooltip

    XMLWordPrintable

    Details

      Description

      Name: gm110360 Date: 02/09/2004


      FULL PRODUCT VERSION :
      java version "1.4.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
      Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Created an Instance of JTree.Added few nodes to the tree.Some of the nodes have same tooltip text.When mouseover a node tooltip is shown.
      When the mouse is moved down to the node below with same tooltip the tooltip looks like its stuck there .In the program below when mouse is over the first node the tooltip is shown over the second node when mouse is over second node the tooltip still stays at the same place and it stays at same place even when mouse is moved to the 3rd node
      Note: Mouse should be moved before dismissal delay.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the Program below
      mouse over the first node of the tree
      Then move the mouse over the second node
      then move the mouse over the third node

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected to see the tooltip over
      below the second node when mouse is on the second node and
      below the third node when mouse is over third node
      ACTUAL -
        Tooltip is always below the first node

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.tree.*;
      import javax.swing.event.*;

      /**
       * @version 1.0 11/09/98
       */
      class ToolTipTreeNode extends DefaultMutableTreeNode {
        private String toolTipText;
        
        public ToolTipTreeNode(String str, String toolTipText) {
          super(str);
          this.toolTipText = toolTipText;
        }

        public String getToolTipText() {
          return toolTipText;
        }
      }

      public class ToolTipTreeExample extends JFrame {
        public ToolTipTreeExample() {
          super("ToolTipTreeExample");
          String[][] strs = {{"swing", "boat" }, // 0
                             {"platf", "boat"}, // 1
                             {"basic", "boat" }, // 2
                             {"metal", "heavy" }, // 3
                             {"JTree", "three" }}; // 4
                                                   
          ToolTipTreeNode[] nodes = new ToolTipTreeNode[strs.length];
          for (int i=0;i<strs.length;i++) {
            nodes[i] = new ToolTipTreeNode(strs[i][0],strs[i][1]);
          }
          nodes[0].add(nodes[1]);
          nodes[1].add(nodes[2]);
          nodes[1].add(nodes[3]);
          nodes[0].add(nodes[4]);
          JTree tree = new JTree( nodes[0] ){
            public String getToolTipText(MouseEvent evt) {
              if (getRowForLocation(evt.getX(), evt.getY()) == -1) return null;
              TreePath curPath = getPathForLocation(evt.getX(), evt.getY());
              return ((ToolTipTreeNode)curPath.getLastPathComponent()).getToolTipText();
            }
          };
          tree.setToolTipText("");
          JScrollPane sp = new JScrollPane(tree);
          getContentPane().add(sp, BorderLayout.CENTER);
        }

        public static void main(String args[]) {
          ToolTipTreeExample frame = new ToolTipTreeExample();
          frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}
          });
          frame.setSize(300, 150);
          frame.setVisible(true);
        }
      }
       
      ---------- END SOURCE ----------
      (Incident Review ID: 237950)
      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: