The Source for Java Technology Collaboration
User: Password:



Romain Guy

Romain Guy's Blog

Synth Week, File Chooser

Posted by gfx on September 23, 2005 at 10:59 PM | Comments (3)

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 <imageIcon /> 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.


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • That's great news!

    Posted by: markswanson on September 24, 2005 at 07:14 AM

  • I am using JDK 1.5.0_04 and the above properties are not working. Is the code below is correct
















    Posted by: adityagodara on September 28, 2005 at 10:34 AM

  • If you take a look at the bug reports you'll see they've been fixed in the JDK 1.6.0 b53 and not in 1.5.

    Posted by: gfx on September 28, 2005 at 10:48 AM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds