Java 12 added following method in javax.swing.filechooser.FileSystemView:
javax.swing.filechooser.FileSystemView
public File[] getChooserShortcutPanelFiles()
This method returns an array of files representing the values shown by default in the file chooser shortcuts panel.
package com.logicbig.example; import javax.swing.*; import javax.swing.filechooser.FileSystemView; import java.io.File; public class ShortcutPanelFilesExample { public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); JFileChooser chooser = new JFileChooser(); FileSystemView view = chooser.getFileSystemView(); System.out.println("The shortcut panel files: "); File[] chooserShortcutPanelFiles = view.getChooserShortcutPanelFiles(); for (File chooserShortcutPanelFile : chooserShortcutPanelFiles) { System.out.println(chooserShortcutPanelFile); } chooser.showOpenDialog(null); } }
The shortcut panel files: C:\Users\joe\AppData\Roaming\Microsoft\Windows\Recent C:\Users\joe\Desktop C:\Users\joe\Documents This PC Network
Also checkout the reason this method was added.
Dependencies and Technologies Used: