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

JColorChooser.setColor(...) does not notify its PropertyChangeListeners.

XMLWordPrintable

    • sparc
    • solaris_2.5.1



      Name: aaC67449 Date: 11/30/98


      JColorChooser.setColor(...) does not notify its PropertyChangeListeners when changing color, but should.

      javadoc says:"
      public void setColor(Color color)

            Sets the current color of the color chooser to the specified color. This will fire a PropertyChangeEvent for the property named "color".
            Parameters:
                  color - the color to be set in the color chooser
            See Also:
                  JComponent.addPropertyChangeListener(java.beans.PropertyChangeListener)
      "

      see example:
      -------------- Example ------------

      import java.beans.*;
      import java.awt.*;
      import javax.swing.*;
      public class Test extends JApplet{

         public static void main(String argv[]) {
            Color test = new Color(11,12,13);
            JColorChooser c= new JColorChooser();
            
            MyPCL lsnr = new MyPCL(); // create property change listener
            c.addPropertyChangeListener(lsnr);
             
            c.setColor(test); // set new color
            
            if(!lsnr.isNotified()) { // test the listener is notified
                    System.out.println("FAILED.");
            } else {
                  System.out.println("PASSED!");
           }
            
         
        }

      }

      class MyPCL implements PropertyChangeListener {
          boolean notified=false;

          public void propertyChange(PropertyChangeEvent evt) {
             notified=true;
          }
          
          public boolean isNotified() {
             boolean ret=notified;
             notified=false;
             return ret;
          }
      }
      --------------- output----------
      FAILED.



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

            stewilso Steve Wilson (Inactive)
            aalievsunw Artem Aliev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: