Skip to main content

Synth Week, File Chooser

Posted by gfx on September 23, 2005 at 10:59 PM PDT

When you bring up a Swing file chooser in Tiger with the Synth look and feel you get a perfectly blank window. Styling JFileChooser requires bindings for scrollbars, tables, buttons, combo box, buttons, text fields and labels. Needless to say it's a rather difficult task. Despite your efforts you won't unfortunately be able to fully style it. It appears that Tiger provides no way to specify icons for files, directories, drives and floppies, making almost impossible for users to make the difference between a file and a folder. Ouch.

Fear not my friends, for this issue has been addressed by bug fix #4972060. You can now declare a few properties to draw the appropriate icons:

<defaultsProperty key="FileView.directoryIcon" value="directoryIcon" />
<defaultsProperty key="FileView.fileIcon" value="fileIcon" />
<defaultsProperty key="FileView.computerIcon" value="computerIcon" />
<defaultsProperty key="FileView.hardDriveIcon" value="hardDriveIcon" />
<defaultsProperty key="FileView.floppyDriveIcon" value="floppyDriveIcon" />

Note that each value is the ID of an declared in the same style element. Anyway, everything's fine, right? Well... almost.

Contrary to most file choosers, especially Basic, Metal and Windows ones, Synth file chooser is lacking four features: create a new folder, browse to parent folder, go to home directory and the choice between the list view and the detailled view. We therefore tackled bug #4972060. These features appear as three buttons and a couple of toggle buttons on top of the file chooser. You can set their icons in a similar fashion as file view icons:

<defaultsProperty key="FileChooser.newFolderIcon" value="newFolderIcon" />
<defaultsProperty key="FileChooser.upFolderIcon" value="upFolderIcon" />
<defaultsProperty key="FileChooser.homeFolderIcon" value="homeFolderIcon" />
<defaultsProperty key="FileChooser.detailsViewIcon" value="detailsViewIcon" />
<defaultsProperty key="FileChooser.listViewIcon" value="listViewIcon" />

You should now be able to give file choosers the exact appearance you were wishing for.

Related Topics >>