--- old/src/java.desktop/share/classes/javax/swing/filechooser/FileSystemView.java 2018-09-28 14:23:25.342614000 +0530
+++ new/src/java.desktop/share/classes/javax/swing/filechooser/FileSystemView.java 2018-09-28 14:23:23.260582300 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -222,12 +222,10 @@
}
/**
- * Icon for a file, directory, or folder as it would be displayed in
+ * Returns icon for a file, directory, or folder as it would be displayed in
* a system file browser. Example from Windows: the "M:\" directory
* displays a CD-ROM icon.
*
- * The default implementation gets information from the ShellFolder class.
- *
* @param f a File
object
* @return an icon as it would be displayed by a native file chooser
* @see JFileChooser#getIcon
@@ -251,6 +249,42 @@
if (img != null) {
return new ImageIcon(img, sf.getFolderType());
} else {
+ 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 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");
}
}