RFR: 8159055: ImageIcon setImage and constructor can't handle null parameter [v9]

Phil Race prr at openjdk.org
Wed Jun 18 22:27:32 UTC 2025


On Wed, 18 Jun 2025 17:38:22 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   SUmmary fix
>
> 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.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25767#discussion_r2155602006


More information about the client-libs-dev mailing list