<Swing Dev> RFR: 8263472: Specification of JComponent::updateUI doesn't mention that the original implementaiton does nothing [v2]
Alexey Ivanov
aivanov at openjdk.java.net
Thu Mar 18 10:55:39 UTC 2021
On Tue, 16 Mar 2021 12:22:24 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> `@implnote` added
>
> It feels wrong with this `@implNote`.
>
> Subclasses *must still override* the default implementation. Should this statement be included in the regular spec text as it was before? Implementation note could say, “The default implementation doesn't do anything.”
>
> Or alternatively, this change can be rejected at all, leaving the spec as it is now.
> It feels wrong with this `@implNote`.
>
> Subclasses _must still override_ the default implementation. Should this statement be included in the regular spec text as it was before? Implementation note could say, “The default implementation doesn't do anything.”
>
> Or alternatively, this change can be rejected at all, leaving the spec as it is now.
To make it clearer, what I suggest is keeping the old text as it was and adding `@implNote` below like this:
/**
* Resets the UI property to a value from the current look and feel.
* <code>JComponent</code> subclasses must override this method
* like this:
* <pre>
* public void updateUI() {
* setUI((SliderUI)UIManager.getUI(this);
* }
* </pre>
*
* @implNote The default implementation of this method doesn't do anything.
*
* @see #setUI
* @see UIManager#getLookAndFeel
* @see UIManager#getUI
*/
This way, it's more *highlighted* that `JComponent` subclasses must override `updateUI` as shown for the correct behaviour. Then the implementation note will add the missing detail: The default implementation does nothing. So it's not necessary to call the super method from the overridden one.
What do you, @prsadhuk and @mrserb, think?
-------------
PR: https://git.openjdk.java.net/jdk/pull/2955
More information about the swing-dev
mailing list