United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7124373 [macosx] Setting frame icon images causes IllegalArgumentException
7124373 : [macosx] Setting frame icon images causes IllegalArgumentException

Details
Type:
Bug
Submit Date:
2011-12-23
Status:
Closed
Updated Date:
2012-03-23
Project Name:
JDK
Resolved Date:
2012-03-23
Component:
client-libs
OS:
os_x
Sub-Component:
java.awt
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
7u4

Related Reports
Relates:

Sub Tasks

Description
http://java.net/jira/browse/MACOSX_PORT-322 submitted 2011/08/24 by Frank Kline
Hi,
This works perfectly well on Oracle's recently released public Linux and Windows JRE7. As a caveat, I'm unsure of what the icon images are supposed to appear as on Mac as most windows don't seem to have associated icons (besides the dock icon, which appears to be set elsewhere).
I set a few icon images for the current frame:
<div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;><div class=&quot;codeContent panelContent&quot;><pre class=&quot;code-java&quot;>frame = <span class=&quot;code-keyword&quot;>new</span> JFrame(<span class=&quot;code-quote&quot;>&quot;Frame title&quot;</span>);Image icon16 = ...Image icon32 = ...Image icon48 = ...frame.setIconImages(Lists.newArrayList(icon16, icon32, icon48));</pre>

                                    

Comments
EVALUATION

This problem happens when a toolkit image is used as a frame icon.
 Toolkit images need to be prepared before usage, because they are
 loaded and processed asynchronously. Utility class MediaTracker
 can be used to prepare an image.

 If image can not be loaded for any reasons, null CImage is returned.
                                     
2011-12-28
SUGGESTED FIX

http://cr.openjdk.java.net/~bae/7124373/
                                     
2011-12-28
EVALUATION

This is a regression. See next log of javatest run (jar would be attached).
You will see that same jar being run on jdk1.6.0 runs correctly and produce exception being run with jdk1.7

$ /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03-384-10M3511)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-384, mixed mode)

$ /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/java -jar javatest.jar

$ java -version
openjdk version "1.7.0-ea"
OpenJDK Runtime Environment (build 1.7.0-ea-b223)
OpenJDK 64-Bit Server VM (build 21.0-b17, mixed mode)

$ java -jar javatest.jar 
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0
 at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1016)
 at java.awt.image.BufferedImage.<init>(BufferedImage.java:357)
 at sun.lwawt.macosx.CImage$Creator.createFromImage(CImage.java:101)
 at sun.lwawt.macosx.CPlatformWindow.getImageForTarget(CPlatformWindow.java:734)
 at sun.lwawt.macosx.CPlatformWindow.updateIconImages(CPlatformWindow.java:541)
 at sun.lwawt.macosx.CPlatformWindow.setVisible(CPlatformWindow.java:506)
 at sun.lwawt.LWWindowPeer$1.run(LWWindowPeer.java:273)
 at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
 at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
 at java.awt.EventQueue.access$000(EventQueue.java:101)
 at java.awt.EventQueue$3.run(EventQueue.java:666)
 at java.awt.EventQueue$3.run(EventQueue.java:664)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
 at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
 at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:240)
 at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:157)
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:146)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:142)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:134)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
                                     
2011-12-26
EVALUATION

Author: Mike Swingler Date: 24/Aug/11 06:31 PM
Frame icon images currently replace the picture of the window when it is minimized into the Dock. We do not set an icon in the titlebar, since those are reserved for actual filesystem representations, and doing otherwise is a violation of the human interface guidelines.
 
Author: Frank Kline Date: 24/Aug/11 06:38 PM
Thanks for clarifying the expected functionaliy!
 
Author: Yuri Nesterenko Date: 11/Oct/11 11:32 AM
Build: b211
closed/java/awt/Icon/SetIconImageExceptionTest/SetIconImageExceptionTest
 
Author: Taras Ledkov Date: 17/Oct/11 03:05 PM
Build: b213
java/awt/dnd/ImageDecoratedDnDNegative/ImageDecoratedDnDNegative 
Keywords: test-fail-macos
 
Author: Bino George Date: 08/Nov/11 06:42 PM
I tested this on both 10.7.2 and 10.6.8 and I am not seeing any exceptions when calling setIconImages.
Please reopen with a testcase if you can still reproduce it.
 
Author: Frank Kline Date: 09/Nov/11 05:07 AM
Hi Bino,
Looking into this a bit more, it seems like this might have been a symptom of an underlying problem. 
It works fine if I load the images with:
<div class=&quot;panel&quot; style=&quot;border-width: 1px;&quot;><div class=&quot;panelContent&quot;>InputStream resourceAsStream = ...
return ImageIO.read(resourceAsStream);

Author: Taras Ledkov Date: 09/Nov/11 02:30 PM
Reproduced on b216, test:
java/awt/dnd/ImageDecoratedDnDNegative/ImageDecoratedDnDNegative 
But this test case differs from original description. In this case image is used in DnD as the source's dragImage. Exception is similar
 
Author: Bino George Date: 10/Nov/11 06:34 PM
Looks like this test fails on JDK6 as well, so this is not a regression from JDK6
                                     
2011-12-23



Hardware and Software, Engineered to Work Together