RFR: 8159055: ImageIcon setImage and constructor can't handle null parameter [v5]
Alexey Ivanov
aivanov at openjdk.org
Wed Jun 18 17:45:35 UTC 2025
On Tue, 17 Jun 2025 02:46:37 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
>> 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.
I agree that “remove the icon” is confusing.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25767#discussion_r2155066882
More information about the client-libs-dev
mailing list