< prev index next >

src/java.desktop/share/classes/javax/swing/filechooser/FileSystemView.java

Print this page

        

*** 254,263 **** --- 254,299 ---- return UIManager.getIcon(f.isDirectory() ? "FileView.directoryIcon" : "FileView.fileIcon"); } } /** + * 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 <code>File</code> 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(). * * @param folder a <code>File</code> object representing a directory or special folder
< prev index next >