Custom layout managers...
| Newsgroups | gmane.comp.embedded.carlsbad-cubes |
|---|---|
| Message-ID | <[email protected]> |
Is there a way currently to use a custom layout manager?
I may be missing it, but it looks like the only way to do this is to add code to the layoutconverter class.
Just as a quick hack I allowed the layout tag to include the name of a class to be created when it's not recognized by one of the special tags. So your new Swixml tag might look like this
<panel layout="com.toth.MyLayout" >
and it would do a forName and newInstance on that class name. Problem with this approach is that you can't provide parameters to the constructor, but maybe that can be worked in a future version.
Here's the patch, that I generated with TextPad's compare should be similar to diff.
Patch generated by textpad
Compare: (<)C:\proj\swixml\src.bak\org\swixml\converters\LayoutConverter.java (9866 bytes)
with: (>)C:\proj\swixml\src\org\swixml\converters\LayoutConverter.java (10177 bytes)
251a251,260
> } else {
> try {
> Class classname = Class.forName( attr.getValue() );
> lm = (LayoutManager) classname.newInstance();
> } catch ( Exception e ) {//tried, and failed
> if( SwingEngine.DEBUG_MODE ) {
> e.printStackTrace(System.err);
> }
>
> }