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

JLabel and AbstractButton's imageUpdate method should be better specified

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P5
    • 20
    • client-libs
    • None
    • behavioral
    • minimal
    • Minimal - clarifying documentation change - no code changes.
    • Java API
    • SE

    Description

      Summary

      Update the java doc for the imageUpdate method of JLabel and AbstractButton to better describe the handling of the image parameter.

      Problem

      The imageUpdate method for both JLabel and AbstractButton currently states that "if the current {@code Icon}'s image is not equal to the passed in image the method will return false".

      This is not correct since Icons don't have an image, it would be an instance of ImageIcon that contains an image.

      Nor is that sufficiently precise. In the case of JLabel if it is not showing then also this method return false. Similarly in the case of AbstractButton if the button for current button state is null then this method also returns false.

      Solution

      Update the documentation for these methods to be more accurate.

      Specification

      javax.swing.JLabel.imageUpdate(Image img, int infoflags, int x, int y, int w, int h) :

      /**
      -     * This is overridden to return false if the current Icon's Image is
      -     * not equal to the passed in Image <code>img</code>.
      +     * If the component is not showing or either the icon or disabled
      +     * icon is not an {@code ImageIcon} with an  {@code Image}
      +     * equal to the passed in {@code Image}, return {@code false};
      +     * otherwise it will delegate to the super-class.
      
       public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h)

      javax.swing.AbstractButton.imageUpdate(Image img, int infoflags, int x, int y, int w, int h) :

      /**
      -     * This is overridden to return false if the current <code>Icon</code>'s
      -     * <code>Image</code> is not equal to the
      -     * passed in <code>Image</code> <code>img</code>.
      +     * If the button icon for the current button state is either  {@code null}
      +     * or not an {@code ImageIcon} with an {@code Image} equal to the
      +     * passed in {@code Image}, return {@code false}; otherwise it
      +     * will delegate to the super-class.
      
       public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h)

      Attachments

        Issue Links

          Activity

            People

              abhiscxk Abhishek Kumar
              svioletsunw Scott Violet (Inactive)
              Philip Race, Prasanta Sadhukhan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: