RFR: 8159055: ImageIcon.setImage can't handle null parameter [v5]

Prasanta Sadhukhan psadhukhan at openjdk.org
Tue Jun 17 02:49:31 UTC 2025


On Mon, 16 Jun 2025 15:21:33 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Fix for constructor
>
> src/java.desktop/share/classes/javax/swing/ImageIcon.java line 373:
> 
>> 371:     /**
>> 372:      * Sets the image displayed by this icon.
>> 373:      * Setting null image will not render any image icon.
> 
> Suggestion:
> 
>      * Setting a {@code null} image will not render any image icon.
> 
> 
> Will it sound clearer if the text stated, _“Setting a `{@code null}` image will remove the icon?”_

I didnt use "remove the icon" as there are 2 possibilities. 
- Already there is existing ImageIcon with image set so if now ImageIcon.setImage(null) is called, it will remove the existing icon and thereafter will not render any image icon
- If there is no ImageIcon set, calling ImageIcon.setImage(null) will not render any image icon so no question of removing the icon
so in both possibilities, there is no imageicon rendered for null image so I chose that phrase.

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

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


More information about the client-libs-dev mailing list