Re: FileChooser

Frank Meissner <[email protected]> Thu, 06 Jan 2005 17:18:09 +0100
Newsgroups gmane.comp.embedded.carlsbad-cubes
Message-ID <[email protected]>
Pavan Sara wrote:
> I'm new with Swixml and I'd like to know if Swixml covers entirely whole
> swing.
> For example I have a swing Gui which uses classes like FileChooser and
> FileFilter.
> How can I have these kinds of classes with swixml?
> Do I have to create my tag?

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

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());

> 
> Do anyone else have problems running the swixml demo sample called "new
> tag"?
> I've the following error: "Resource could not be found xml/XPanel.xml".
> Is it possible that the downloaded package misses such a file?

Indeed, you are correct. The file is missing. From the context I assume 
any xml file containing a panel definition will do. For the time beeing, 
try the attached one.

Hope it helps,

Frank

_______________________________________________
Forum mailing list
[email protected]
http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com
XPanel.xml (text/xml, 279 B)
<?xml version="1.0" encoding="UTF-8"?>
<panel constraints="BorderLayout.CENTER">
    <label labelfor="tf" font="Georgia-BOLD-12" foreground="blue" text="Hello World!"/>
    <textfield id="tf" columns="20" Text="Swixml"/>
    <button text="Click Here" action="submit"/>
</panel>