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

JTree is sending incorrect active descendant events

    Details

      Backports

        Description



        Name: pa48320 Date: 12/04/2001


        Using the following testcase tab into the JTree and then use the up
        and down arrows to navigate to different items. Notice that the JTree
        is firing active descendant events that are incorrect. The event
        that is currently being sent is always sending the last node as the
        new node instead of the correct new node.

        import javax.accessibility.*;
        import java.beans.*;
        import javax.swing.*;
        import javax.swing.text.*;

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

        public class TreeTest extends JPanel implements PropertyChangeListener
        {
            public static void main(String[] args)
            {
                 TreeTest p = new TreeTest();
                 JFrame f = new JFrame("Test JTree Accessibilty");
                 f.getContentPane().setLayout(new BorderLayout());
                 f.getContentPane().add(BorderLayout.NORTH, p);
                 f.pack();
                 f.setVisible(true);
            }

            public TreeTest() {
          setLayout(new BorderLayout());

                DefaultMutableTreeNode top = new DefaultMutableTreeNode("Music");
                DefaultMutableTreeNode catagory;
          DefaultMutableTreeNode composer;
          DefaultMutableTreeNode style;
          DefaultMutableTreeNode album;

          // Classical
          catagory = new DefaultMutableTreeNode("Classical");
          top.add(catagory);

          // Beethoven
          catagory.add(composer = new DefaultMutableTreeNode("Beethoven"));
          // Brahms
          catagory.add(composer = new DefaultMutableTreeNode("Brahms"));

          // Mozart
          catagory.add(composer = new DefaultMutableTreeNode("Mozart"));
          catagory.add(composer = new DefaultMutableTreeNode("Schubert"));

          // Jazz
          top.add(catagory = new DefaultMutableTreeNode("Jazz"));

          // Ayler
          catagory.add(composer = new DefaultMutableTreeNode("Albert Ayler"));

          // Chet Baker
          catagory.add(composer = new DefaultMutableTreeNode("Chet Baker"));

          // Coltran
          catagory.add(composer = new DefaultMutableTreeNode("John Coltrane"));

          // Miles
          catagory.add(composer = new DefaultMutableTreeNode("Miles Davis"));

          // Rock
          top.add(catagory = new DefaultMutableTreeNode("Rock"));

          // The Beatles
          catagory.add(composer = new DefaultMutableTreeNode("The Beatles"));
          // Crowded House
          catagory.add(composer = new DefaultMutableTreeNode("Crowded House"));

          // Harvin Garvel
          catagory.add(composer = new DefaultMutableTreeNode("Harvin Garvel"));

          // The Steve Miller Band
          catagory.add(composer = new DefaultMutableTreeNode("Steve Miller Band"));
          JTree tree = new JTree(top);
          add(new JScrollPane(tree), BorderLayout.CENTER);

          tree.getAccessibleContext().addPropertyChangeListener(this);
            }

          public void propertyChange(PropertyChangeEvent e)
          {
            String name = e.getPropertyName();
            if (AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY.equals(name))
            {
                System.out.println("active descendant changed");

             AccessibleContext oldAC = (AccessibleContext)e.getOldValue();
             String old = (oldAC == null) ? null : oldAC.getAccessibleName();
             System.out.println("old descendant is " + old);

             AccessibleContext ac = (AccessibleContext)e.getNewValue();
             System.out.println("new descendant is " + ac.getAccessibleName());
            }
          }
        }
        (Review ID: 136689)
        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  lmonsantsunw Lynn Monsanto (Inactive)
                  Reporter:
                  pallenba Peter Allenbach (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: