< prev index next >

src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java

Print this page
rev 13901 : Fixes for 8151385. Contains additional fix for 8149453 (upFolder, newFolder, etc. icons)
rev 13629 : 8138838: docs cleanup for java.desktop
Summary: docs cleanup for java.desktop
Reviewed-by: serb
rev 13226 : 8030099: Memory usage of java process increases after pressing start button in test window
Reviewed-by: prr, serb
rev 12267 : 8022057: JFileChooser blocks EDT in Win32ShellFolder2.getIcon
Reviewed-by: serb, ant
rev 12260 : 8017487: filechooser in Windows-Libraries folder: columns are mixed up
Reviewed-by: serb, ant
rev 12117 : 8003399: JFileChooser gives wrong path to selected file when saving to Libraries folder on Windows 7
Reviewed-by: serb, ant
rev 11099 : 8067377: My hobby: caning, then then canning, the the can-can
Summary: Fix ALL the stutters!
Reviewed-by: rriggs, mchung, lancea
rev 10444 : 8054834: Modular Source Code
Reviewed-by: alanb, chegar, ihse, mduigou
Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com

@@ -980,32 +980,34 @@
                                                boolean useVGAColors);
                                                // Note: useVGAColors is ignored on XP and later
 
     // Return the bits from an HICON.  This has a side effect of setting
     // the imageHash variable for efficient caching / comparing.
-    private static native int[] getIconBits(long hIcon, int iconSize);
+    private static native int[] getIconBits(long hIcon);
     // Dispose the HICON
     private static native void disposeIcon(long hIcon);
 
-    static native int[] getStandardViewButton0(int iconIndex);
+    // Get buttons from native toolbar implementation.
+    static native int[] getStandardViewButton0(int iconIndex, boolean small);
 
     // Should be called from the COM thread
     private long getIShellIcon() {
         if (pIShellIcon == -1L) {
             pIShellIcon = getIShellIcon(getIShellFolder());
         }
 
         return pIShellIcon;
     }
 
-    private static Image makeIcon(long hIcon, boolean getLargeIcon) {
+    private static Image makeIcon(long hIcon) {
         if (hIcon != 0L && hIcon != -1L) {
             // Get the bits.  This has the side effect of setting the imageHash value for this object.
-            int size = getLargeIcon ? 32 : 16;
-            int[] iconBits = getIconBits(hIcon, size);
+            final int[] iconBits = getIconBits(hIcon);
+            // icons are always square
+            final int size = (int)Math.sqrt(iconBits.length);
             if (iconBits != null) {
-                BufferedImage img = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
+                final BufferedImage img = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
                 img.setRGB(0, 0, size, size, iconBits, 0, size);
                 return img;
             }
         }
         return null;

@@ -1044,11 +1046,11 @@
                                     imageCache = getLargeIcon ? largeSystemImages : smallSystemImages;
                                 }
                                 newIcon = imageCache.get(Integer.valueOf(index));
                                 if (newIcon == null) {
                                     long hIcon = getIcon(getAbsolutePath(), getLargeIcon);
-                                    newIcon = makeIcon(hIcon, getLargeIcon);
+                                    newIcon = makeIcon(hIcon);
                                     disposeIcon(hIcon);
                                     if (newIcon != null) {
                                         imageCache.put(Integer.valueOf(index), newIcon);
                                     }
                                 }

@@ -1069,11 +1071,11 @@
                                     } else {
                                         return getShell32Icon(1, getLargeIcon);
                                     }
                                 }
                             }
-                            newIcon = makeIcon(hIcon, getLargeIcon);
+                            newIcon = makeIcon(hIcon);
                             disposeIcon(hIcon);
                         }
 
                         if (newIcon == null) {
                             newIcon = Win32ShellFolder2.super.getIcon(getLargeIcon);

@@ -1093,11 +1095,11 @@
     /**
      * Gets an icon from the Windows system icon list as an {@code Image}
      */
     static Image getSystemIcon(SystemIcon iconType) {
         long hIcon = getSystemIcon(iconType.getIconID());
-        Image icon = makeIcon(hIcon, true);
+        Image icon = makeIcon(hIcon);
         disposeIcon(hIcon);
         return icon;
     }
 
     /**

@@ -1114,11 +1116,11 @@
             useVGAColors = shellIconBPP.equals("4");
         }
 
         long hIcon = getIconResource("shell32.dll", iconID, size, size, useVGAColors);
         if (hIcon != 0) {
-            Image icon = makeIcon(hIcon, getLargeIcon);
+            Image icon = makeIcon(hIcon);
             disposeIcon(hIcon);
             return icon;
         }
         return null;
     }
< prev index next >