Pavan Sara | 10 Jan 2005 09:45
Picon

Re: FileChooser


Frank Meissner wrote:

> If you really mean FileChooser, then you really need to define your 
> own tag, because this is no swing class at all. For the class 
> JFileChooser, I do not see a problem there. Because you mention the 
> class FileFilter, I guess you want to do something like this:
> <filechooser filter="*.xyz">...</filechooser>
> ?
>
Sorry, you're right, I meant JFileChooser.
But the solution isn't clear for me yet.
Can I put a JFileChooser object without writing Java code, but only 
using xml?
The number of swixml tag is small and  there are several swing 
components I don't know
how to obtain.
When you wrote the tag filechooser, it is my own tag, isn't it?

> Because there exists no converter for this kind of attribute (type 
> FileFilter, input "*.xyz"), you have to write your own tag or your own 
> converter. AFAIK the converter may be written somewhat like this:
> public class FileFilterConverter implements org.swixml.Converter {
>   public Object convert(Class tpe, Attribute attr, Localizer loc) {
>     // write code to return a valid javax.swing.filechooser.FileFilter
>     // it should work on the attr parameter
>   }
>   public Class convertsTo() {
>     return javax.swing.filechooser.FileFilter.class;
>   }
> }
>
> You register this converter through:
> ConverterLibrary cl = ConverterLibrary.getInstance();
> cl.register(javax.swing.filechooser.FileFilter.class, new 
> FileFilterConverter());
>
For the second part of your answer, I'll try.
Thank you for your help,
S.

Gmane