changeset 4637:b35e80eb4475

7124373: [macosx] Setting frame icon images causes IllegalArgumentException Reviewed-by: anthony
author bae
date Thu, 29 Dec 2011 12:21:21 +0300
parents dd45e1667b76
children abae34c163a2
files src/macosx/classes/sun/lwawt/macosx/CImage.java
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/classes/sun/lwawt/macosx/CImage.java	Wed Dec 28 22:10:42 2011 +0300
+++ b/src/macosx/classes/sun/lwawt/macosx/CImage.java	Thu Dec 29 12:21:21 2011 +0300
@@ -96,6 +96,20 @@
         // This is used to create a CImage from a Image
         public CImage createFromImage(final Image image) {
             if (image == null) return null;
+
+            MediaTracker mt = new MediaTracker(new Label());
+            final int id = 0;
+            mt.addImage(image, id);
+
+            try {
+                mt.waitForID(id);
+            } catch (InterruptedException e) {
+            }
+
+            if (mt.isErrorID(id)) {
+                return null;
+            }
+
             int w = image.getWidth(null);
             int h = image.getHeight(null);
             BufferedImage bimg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);