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

Specification of JComponent::updateUI should document that the default implementation does nothing

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 17
    • client-libs
    • None
    • behavioral
    • minimal
    • No behavior change - specification only so minimal risk
    • Java API
    • SE

      Summary

      It's unclear from the spec that the original implementation of the method does nothing in https://docs.oracle.com/en/java/javase/15/docs/api/java.desktop/javax/swing/JComponent.html#updateUI()

      Problem

      The current state of specification for https://docs.oracle.com/en/java/javase/15/docs/api/java.desktop/javax/swing/JComponent.html#updateUI() is unclear that the original implementation of the method does nothing. This deserves to be mentioned explicitly.

      Solution

      javadoc updated to mention that the base method does not do anything via @implSpec tag.

      Specification

          /**
      -     * Resets the UI property to a value from the current look and feel.
      -     * <code>JComponent</code> subclasses must override this method
      +     * This method is called to update the UI property to a value from the
      +     * current look and feel.
      +     * {@code JComponent} subclasses must override this method
            * like this:
            * <pre>
            *   public void updateUI() {
            *      setUI((SliderUI)UIManager.getUI(this);
            *   }
            *  </pre>
            *
      +     * @implSpec The default implementation of this method does nothing.
      +     *
            * @see #setUI
            * @see UIManager#getLookAndFeel
            * @see UIManager#getUI
            */
           public void updateUI() {}

            psadhukhan Prasanta Sadhukhan
            dbessono Dmitry Bessonov
            Philip Race
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: