Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8188238

Access to Windows Large Icons

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 17
    • Component/s: client-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      API sun.awt.shell.ShellFolder.getShellFolder(file).getIcon(getLargeIcon) in the sun package is now considered internal and is not exposed since Java-9 so a replacement API is added to Swing's FileSystemView.

      Problem

      Customers requested ability to query higher resolution icon for files with functionality at least matching the functionality of the now inaccessible API.

      Solution

      Add a new method to javax.swing.filechooser.FileSystemView that allows querying icon of the specific size. Method should return the icon of the best available quality based on the requested icon size associated with the specified file. Whenever possible we should return the multi resolution icon that can be used to display said icon on displays with different magnification factors.

      Specification

      Webrev: https://openjdk.github.io/cr/?repo=jdk&pr=2875&range=06

      +   /**
      +    * Returns an icon for a file, directory, or folder as it would be displayed
      +    * in a system file browser for the requested size.
      +    * <p>
      +    * Example: <pre>
      +    *     FileSystemView fsv = FileSystemView.getFileSystemView();
      +    *     Icon icon = fsv.getSystemIcon(new File("application.exe"), 64, 64);
      +    *     JLabel label = new JLabel(icon);
      +    * </pre>
      +    *
      +    * @implSpec The available icons may be platform specific and so the
      +    * available sizes determined by the platform. Therefore an exact match
      +    * for the requested size may not be possible.
      +    *
      +    * The icon returned may be a multi-resolution icon image,
      +    * which allows better support for High DPI environments
      +    * with different scaling factors.
      +    *
      +    * @param f a {@code File} object for which the icon will be retrieved
      +    * @param width width of the icon in user coordinate system.
      +    * @param height height of the icon in user coordinate system.
      +    * @return an icon as it would be displayed by a native file chooser
      +    * or null for a non-existent or inaccessible file.
      +    * @throws IllegalArgumentException if an invalid parameter such
      +    * as a negative size or a null file reference is passed.
      +    * @see JFileChooser#getIcon
      +    * @see AbstractMultiResolutionImage
      +    * @see FileSystemView#getSystemIcon(File)
      +    * @since 17
      +    */
      +    public Icon getSystemIcon(File f, int width, int height) {
      +        // implementation omitted
      +        }
      +
           /**
            * On Windows, a file can appear in multiple folders, other than its
            * parent directory in the filesystem. Folder could for example be the

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              kizune Alexander Zuev
              Reporter:
              shadowbug Shadow Bug
              Reviewed By:
              Alexander Zvegintsev, Alexey Ivanov
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: