English 中文(简体)
Swing: JFileChooser with favorites?
原标题:

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?

最佳回答

While the JFileChooser accessory was intended to be used for things like thumbnails of the currently selected file, per the JavaDocs:

An accessory is often used to show a preview image of the selected file; however, it can be used for anything that the programmer wishes, such as extra custom file chooser controls.

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.

问题回答

There are already some libraries in Java of "favorites" feature, you can use, for example, this one.





相关问题
auto abbreviating JLabel

Anyone written a JLabel (extension/util/??) that automatically abbreviates the contents depending on it s preferred/visible size? much appreciated.

how can install swing/matisse on eclipse?

i tried this link: http://downloads.myeclipseide.com/downloads/products/eworkbench/discovery-6.0/ but i m fail how is this?

Java JTextField with input hint

I would like to add a hint value to my javax.swing.JTextField. It should look like Firefox rendering of <input type="text" title="bla">. This creates an edit field with the text bla in the ...

Swing Generator

I need to develop some java gui using swing. A few years ago I did develop a bit with swing. But it was pretty exhausting, you see, back than there weren t much tools to help you. But I do believe ...

Create a ImageIcon that is the mirror of another one

I ll like to know if there is a way to create a ImageIcon that is the mirror of another ImageIcon. Searching on Google, I found how to do it by using many AWT libraries. Is there a way to do it with ...

热门标签