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

JTree causes new Nodes to be unselectable when rowHeight and largeModel are set

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.2, 1.3.0
    • client-libs
    • beta
    • x86
    • windows_98, windows_nt



      Name: rl16235 Date: 06/16/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Classic VM (build 1.3.0-C, native threads, nojit)

      I built up a JTree and added a new node at the bottom, under an already
      extended parent-node. This new node could not be selected by a mouseclick or by
      using the keyboard.

      This testprogram shows such a JTree. To reproduce that problem you have to open
      the TreeNode "c" and then use the button to fill in a new entry under TreeNode
      "c".

      The problem doesn't occur when either setRowHeight(21) or setLargeModel(true)
      is not called.


      import javax.swing.*;
      import javax.swing.tree.*;
      import java.awt.*;
      import java.awt.event.*;

      public class EasyTreeTest2
      {
          public static void main(String P_params[])
          {
              JFrame frame = new JFrame();
              frame.addWindowListener (new WindowAdapter()
              {
                  public void windowClosing(WindowEvent e) { System.exit(0); }
              });

              frame.getContentPane().setLayout(new FlowLayout(FlowLayout.LEFT, 40,40));

              final JTree t = new JTree();

              t.setRowHeight(21);
              t.setLargeModel(true);

              t.setPreferredSize(new Dimension(100, 200));
              DefaultMutableTreeNode root = new DefaultMutableTreeNode("");
              t.setRootVisible(false);
              DefaultMutableTreeNode a = new DefaultMutableTreeNode("a");
              DefaultMutableTreeNode b = new DefaultMutableTreeNode("b");
              final DefaultMutableTreeNode c = new DefaultMutableTreeNode("c");
              root.add(a);
              root.add(b);
              root.add(c);
              c.add(new DefaultMutableTreeNode("c1"));
              c.add(new DefaultMutableTreeNode("c2"));
              t.setModel(new DefaultTreeModel(root, false));

              frame.getContentPane().add(t);

              final JTextField tf = new JTextField(10);
              JButton bu = new JButton("eini");
              bu.addActionListener(new ActionListener()
              {
                  public void actionPerformed(ActionEvent e)
                  {
                      c.add(new DefaultMutableTreeNode(tf.getText()));
                      ((DefaultTreeModel)t.getModel()).reload(c);
                  }
              });
              frame.getContentPane().add(tf);
              frame.getContentPane().add(bu);

              frame.pack();
              frame.setVisible(true);
          }
      }

      ###@###.### 2000-06-16
      Reproduced.
      (Review ID: 105098)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            rlingaiaorcl Ranjit Lingaiah (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: