--- old/src/java.desktop/share/classes/javax/swing/filechooser/FileSystemView.java 2018-09-21 15:19:47.677921300 -0700 +++ new/src/java.desktop/share/classes/javax/swing/filechooser/FileSystemView.java 2018-09-21 15:19:46.537585300 -0700 @@ -256,6 +256,42 @@ } /** + * Icon for a file, directory, or folder as it would be displayed in + * a system file browser for the requested size. + * + * The default implementation gets information from the ShellFolder class. + * + * @param f a File object + * @param size width and height of the icon in pixels to be scaled(valid range: 1 to 256) + * @return an icon as it would be displayed by a native file chooser + * @see JFileChooser#getIcon + * @since 12 + */ + protected Icon getSystemIcon(File f, int size) { + if (f == null) { + return null; + } + + if (size > 256 || size < 1) { + return null; + } + + ShellFolder sf; + try { + sf = getShellFolder(f); + } catch (FileNotFoundException e) { + return null; + } + + Image img = sf.getIcon(size); + if (img != null) { + return new ImageIcon(img, sf.getFolderType()); + } else { + return UIManager.getIcon(f.isDirectory() ? "FileView.directoryIcon" : "FileView.fileIcon"); + } + } + + /** * On Windows, a file can appear in multiple folders, other than its * parent directory in the filesystem. Folder could for example be the * "Desktop" folder which is not the same as file.getParentFile().