Login  Register

Re: OpenDialog with multiple default extensions?

Posted by ctrueden on Jun 30, 2009; 6:14pm
URL: http://imagej.273.s1.nabble.com/about-macro-tp3691848p3691858.html

Hi Joachim,

Michael is correct that java.awt.FileDialog does not support the notion of
user-selectable file filters.

FYI, Bio-Formats provides a JFileChooser with configurable file filters
according to supported file formats, as well as (optional) preview icons for
selected files. You can see it in action by running loci_tools.jar from the
command line ("java -jar loci_tools.jar") and choosing Open from the File
menu. You can also use it in your own GPL code; see the
loci.formats.gui.GUITools.buildFileChooser(*) methods.

Cheers,
Curtis

On Tue, Jun 30, 2009 at 1:05 PM, Michael Schmid <[hidden email]>wrote:

> Hi Joachim,
>
> as far as I can say, ImageJ OpenDialog does not support it.
>
> java.awt.FileDialog has a setFilenameFilter method. There, you can check
> for, e.g., endsWith(".jpg") etc. I think that you can't modify the filter
> while the dialog box is open.
> For a user-defined filter, you need the javax.swing.JFileChooser.
>
>
> The downside of using java.awt.FileDialog or javax.swing.JFileChooser: no
> interfacing to the ImageJ macro langage unless you add code for it yourself.
> Also, the ImageJ default directory is not set.
>
>
> Michael
> ________________________________________________________________
>
>
> On 30 Jun 2009, at 19:49, Joachim Wesner wrote:
>
>  Hi list,
>>
>> maybe it´s a silly question, but I don´t seem to find a solution, also not
>> in the list archive and docs:
>>
>> Is it possible to have an OpenDialog that display a limited number of
>> default file extensions instead of one fixed default filename resp. "*.*"?
>>
>> I would like to limit the filetypes to only certain selections, with
>> probably "*.*" as the ultimate choice. This is very easy with Windows
>> itself, even on a very low level.
>> Can I do it with OpenDialog or is there a replacement?
>>
>> Thanks
>>
>> Joachim
>>
>> Mit freundlichen Grüßen / Best regards
>>
>> Joachim Wesner
>> Projektleiter Optik Technologiesysteme
>>
>