This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 157254

Summary: ImageUtilities.loadIcon is missing
Product: platform Reporter: Jaroslav Tulach <jtulach>
Component: -- Other --Assignee: apireviews <apireviews>
Severity: blocker CC: t_h
Priority: P3 Keywords: API_REVIEW_FAST
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: patch
new patch JG01+Y01
API change patch
usage patch

Description Jaroslav Tulach 2009-01-21 16:49:33 UTC
Please simplify following changeset
by introducing ImageUtilities.loadIcon(String,...)
Comment 1 t_h 2009-01-26 14:16:27 UTC
Created attachment 76238 [details]
Comment 2 Jaroslav Tulach 2009-01-26 14:49:58 UTC
Y01 I miss some small, simple test. Otherwise OK.
Comment 3 Milos Kleint 2009-01-26 15:05:39 UTC
looks ok to me.

contrary to jtulach's opinion, I don't think tests of any sort is to be part of the apireview process. it might be
helpful in complex changes to see the api usage, but here it is not serving any purpose.
Comment 4 Jesse Glick 2009-01-26 16:08:51 UTC
[JG01] Javadoc must emphasize that the returned Icon may not be an ImageIcon. This is relevant because Swing components
which grey out when disabled (such as JButton) will generally not work correctly with this method - you really need to
use "new ImageIcon(loadImage(...))". So the method should only be used for situations where it is known that the icon
will not be used for a button, menu item, etc., or if it is, that the button will always be enabled.
Comment 5 t_h 2009-01-27 15:07:16 UTC
> [JG01]
Ok, maybe it would be better to return ImageIcon all the time.
Comment 6 t_h 2009-01-27 15:08:40 UTC
Created attachment 76270 [details]
new patch JG01+Y01
Comment 7 Jesse Glick 2009-01-27 15:55:47 UTC
If you're going to make that change, then you should remove the warning from the Javadoc of image2Icon. (I'm not sure if
there would even be any remaining purpose in the image2Icon method - it would do nothing more than cache ImageIcon
instances for images coming from loadImage, which may or may not be helpful.)

Consider searching for existing code which could use the new method. In Jackpot syntax:

org.openide.util.ImageUtilities.image2Icon(org.openide.util.ImageUtilities.loadImage($r)) =>
org.openide.util.ImageUtilities.loadIcon($r, false);
org.openide.util.ImageUtilities.image2Icon(org.openide.util.ImageUtilities.loadImage($r, $l)) =>
org.openide.util.ImageUtilities.loadIcon($r, $l);
new javax.swing.ImageIcon(org.openide.util.ImageUtilities.loadImage($r)) => org.openide.util.ImageUtilities.loadIcon($r,
new javax.swing.ImageIcon(org.openide.util.ImageUtilities.loadImage($r, $l)) =>
org.openide.util.ImageUtilities.loadIcon($r, $l);
new javax.swing.ImageIcon(org.openide.util.Utilities.loadImage($r)) => org.openide.util.ImageUtilities.loadIcon($r, false);
new javax.swing.ImageIcon(org.openide.util.Utilities.loadImage($r, $l)) => org.openide.util.ImageUtilities.loadIcon($r, $l);
Comment 8 t_h 2009-02-09 11:07:58 UTC
Created attachment 76733 [details]
API change patch
Comment 9 t_h 2009-02-09 11:09:06 UTC
Created attachment 76734 [details]
usage patch
Comment 10 Jesse Glick 2009-02-09 14:32:12 UTC
The Javadoc for loadImageIcon seems to be referring to itself.

Don't forget that usages would need to be matched by spec version increments in the module deps.
Comment 11 t_h 2009-02-11 15:40:02 UTC
Thanks for review. I updated dependencies and fixed Javadoc.
core-main #94f783e8a5a3
core-main #5dc32844e809
Comment 12 Quality Engineering 2009-02-13 09:25:00 UTC
Integrated into 'main-golden', will be available in build *200902130336* on (upload may still be in progress)
User: Tomas Holy <>
Log: #157254: ImageUtilities.loadIcon is missing