Login  Register

Antwort: Re: OpenDialog with multiple default extensions?

Posted by Joachim Wesner on Jul 08, 2009; 8:53am
URL: http://imagej.273.s1.nabble.com/about-macro-tp3691848p3691859.html

Hi Curtis and Michael,

thanx for the info. Yes the correct expression is actually a "file filter"
here.

I was/am actually a bit confused (resp. expected more) because the standard
OpenDialog when using JFileChooser seems to already handle correctly a
*single* extension as
a respective file filter resp "file type" and displays the appropriate
dialog, so I thought adding more extensions would be very easy.

I have taken a look at the OpneDialog source code and the filter examples
on the Java tutorials page and probably can come up with an extended,
"backward compatible"
OpenDialog, let´s see if/when I get some more time to work on it.

Thanx again

Mit freundlichen Grüßen / Best regards

Joachim Wesner
Projektleiter Optik Technologiesysteme


Leica Microsystems CMS GmbH | GmbH mit Sitz in Wetzlar | Amtsgericht
Wetzlar  HRB 2432
Geschäftsführer:  Dr. Stefan Traeger | Dr. Wolf-Otto Reuter | Dr. David Roy
Martyr | Colin Davis


                                                                           
             Curtis Rueden                                                
             <[hidden email]                                            
             U>                                                         An
             Gesendet von:              [hidden email]                
             ImageJ Interest                                         Kopie
             Group                                                        
             <[hidden email].                                       Thema
             GOV>                       Re: OpenDialog with multiple      
                                        default extensions?                
                                                                           
             30.06.2009 20:14                                              
                                                                           
                                                                           
              Bitte antworten                                              
                    an                                                    
              ImageJ Interest                                              
                   Group                                                  
             <[hidden email].                                            
                   GOV>                                                    
                                                                           
                                                                           




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
>>
>



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________