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

AccessibleJComponent does not generate PropChangeEvent when children added

XMLWordPrintable

    • kestrel
    • sparc
    • solaris_2.5.1



      Name: aaC67449 Date: 07/21/99



      The JComponent.AccessibleJComponent.accessibleContainerHandler variable
      is not used now.

      So an AccessibleContainerHandler listener is not created and not added to The JComponent.
      Thus the PropertyChangeEvent is not generated when children added/removed, but should.

      javadoc says:"
      protected class JComponent.AccessibleJComponent.AccessibleContainerHandler
      extends Object
      implements ContainerListener

      Fire PropertyChange listener, if one is registered, when children added/removed.
      "

      This is incompatible change and the behavior should be restored,
      namely the accessibleContainerHandler variable should contain a correct listener
      and the listener should be added to JComponent.

      See example.
      ------------- example --------------
      import javax.swing.*;
      import javax.accessibility.*;
      import java.beans.*;

      public class Test {
          public static void main(String argv[]) {
       
              JPanel c=new JPanel();

              MyPropertyChangeListener listener = new MyPropertyChangeListener();
              c.getAccessibleContext().addPropertyChangeListener(listener);
           
              c.add(new JButton());
             
              if(listener.added) {
                  System.out.println("Passed");
              } else {
                  System.out.println("Method does not notify listener");
              }
         
          }

      }

      class MyPropertyChangeListener implements PropertyChangeListener {
          public boolean added = false;

          public void propertyChange(PropertyChangeEvent evt) {
              added = true;
          }
      }
      ------------- JDK1.3L output ---------------
      Warning: JIT compiler "sunwjit" not found. Will use interpreter.
      Method does not notify listener
      ------------- JDK1.3F output ---------------
      Passed

      ======================================================================

            pkorn Peter Korn (Inactive)
            alisunw Ali Ali (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: