I’m working on an application which needs to select files. JFileChooser is a great start, but I need to augment it. I can start it at one particular directory with JFileChooser.setCurrentDirectory(), but how can I offer the user a “favorites” functionality, either in terms of favorite files saved for later, or favorite directories to jump to?
I’m working on an application which needs to select files. JFileChooser is a great
Share
While the JFileChooser accessory was intended to be used for things like thumbnails of the currently selected file, per the JavaDocs:
So you’ll have to create a custom JComponent to represent “favorite directories”, then call
setAccessory(myFavesComponent)on your file chooser.To actually implement the storage of favorite directories, you’ll want to use the Preferences API.