/** * Return the user's default starting directory for the file chooser. * * @return a <code>File</code> object representing the default starting folder * @since 1.4 */ public File getDefaultDirectory() { File f = (File) ShellFolder.get("fileChooserDefaultFolder"); if (isFileSystemRoot(f)) { f = createFileSystemRoot(f); } return f; }
/** * Returns all root partitions on this system. For example, on Windows, this would be the * "Desktop" folder, while on DOS this would be the A: through Z: drives. */ public File[] getRoots() { // Don't cache this array, because filesystem might change File[] roots = (File[]) ShellFolder.get("roots"); for (int i = 0; i < roots.length; i++) { if (isFileSystemRoot(roots[i])) { roots[i] = createFileSystemRoot(roots[i]); } } return roots; }
public static void main(String[] args) { if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) { System.out.println("The test was skipped because it is sensible only for Windows."); return; } for (String key : KEYS) { Image image = (Image) ShellFolder.get(key); if (image == null) { throw new RuntimeException("The image '" + key + "' not found."); } if (image != ShellFolder.get(key)) { throw new RuntimeException("The image '" + key + "' is not cached."); } } System.out.println("The test passed."); }