RFR: 8159055: ImageIcon.setImage and ImageIcon(Image) constructor can't handle null parameter [v9]
Prasanta Sadhukhan
psadhukhan at openjdk.org
Thu Jun 19 03:01:16 UTC 2025
On Wed, 18 Jun 2025 22:18:45 GMT, Phil Race <prr at openjdk.org> wrote:
>> src/java.desktop/share/classes/javax/swing/ImageIcon.java line 374:
>>
>>> 372: /**
>>> 373: * Sets the image displayed by this icon.
>>> 374: * Setting a {@code null} image will not render any image icon.
>>
>> Suggestion:
>>
>> * Setting a {@code null} image renders no icon.
>>
>> I think this is better: it's shorter, it uses the present tense because it's fact and it doesn't depend on anything.
>
> I think the existing text was OK. And "will" is better because it hasn't happened yet.
> Rendering will happen later. Not when you construct this object.
> My personally preferred wording would be something like
> Setting a {@code null} image means any existing image will be removed and no image will be rendered.
>
> Now .. what should happen to an existing description when you set a new image ?
>
> Apps can call setDescription() but in what order ?
>
> The only thing I can say here is that I think if the image is null we probably should clear the description.
I have modified the wording as per suggestion and also clearing the description now if image is null..
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25767#discussion_r2155944533
More information about the client-libs-dev
mailing list