-
CSR
-
Resolution: Unresolved
-
P4
-
None
-
source
-
minimal
-
SE
Summary
If ImageIcon.setImage(
) receives a null
image as parameter, it should remove the currently displayed icon.
Problem
ImageIcon.setImage
receives an Image
object as parameter. If it is null
, then method throws NullPointerException
from the loadImage
method after it creates MediaTracker
to track loading the image, which is unnecessary since image is null.
Solution
Bail out early if null
Image is passed. A null
image does not render any icon.
Specification
javax.swing.ImageIcon
/**
* Creates an ImageIcon from an image object.
+ * Setting a {@code null} image will not render any image icon.
* If the image has a "comment" property that is a string,
public ImageIcon (Image image) {
/**
* Sets the image displayed by this icon.
+ * Setting a {@code null} image will not render any image icon.
* @param image the image
*/
public void setImage(Image image) {
- csr of
-
JDK-8159055 ImageIcon.setImage can't handle null parameter
-
- Open
-