views:

115

answers:

3

I need a nautilus-style file picker in java, where the files are shown "gallery-style" with a customisable thumbnail for each file. Is it possible to make the standard open file dialog do this? If not, does anyone know of an open-sourced widget that I can use?

+2  A: 

The JFileChooser allows you access to a custom area where you can add whatever UI elements you'd like. It's available via setAccessory(JComponent) as documented in the javadoc.

davetron5000
no, i don't want an accessory for the whole filechooser, i want one callback per file to display its thumbnail preview as its icon
Martin DeMello
+2  A: 

I want one callback per file to display its thumbnail preview as its icon.

I think @davetron5000 suggestion may still be useful: As shown in How to Use File Choosers, the FileChooserDemo2 example demonstrates an approach to constructing thumnails. It's not exactly what you're looking for, but it may be a good starting point. You'd update your preview pane in response to DIRECTORY_CHANGED_PROPERTY, rather than SELECTED_FILE_CHANGED_PROPERTY.

Addendum: org.netbeans.swing.outline.Outline with a custom TableCellRenderer might be an interesting alternative.

trashgod
my problem with a preview pane is you need to click on each file before you can see its preview. that really doesn't scale if the user needs to pick from a list of images whose filenames are meaningless.
Martin DeMello
Link updated. `DIRECTORY_CHANGED_PROPERTY` provides access to the whole directory; you'd have to fire the event manually for the initial level and synchronize selections. The example depends on a file's extension, but sniffing might be possible.
trashgod
thanks,missed the DIRECTORY_CHANGED_PROPERTY. still feels a bit like i'm fighting with the jfilechooser, but i'll mark this as accepted
Martin DeMello
I empathize with the "fighting" aspect of this approach. Rather than adding a new answer, I've suggested an alternative above.
trashgod
excellent! they even have a file manager as an example
Martin DeMello
A: 

I suppose nautilus is the KDE file manager.

I don't no if that is available for KDE, but for Windows i usally use the (Eclipse) SWT file chooser, because it is more native than the pure Swing implementation.

Example here

PeterMmm
nautilus is the gnome file manager. but i just presented it as an example of the ui i want. i don't want a native file manager, i want a gallery widget where the user can select a file by thumbnail rather than filename.
Martin DeMello