Dear Friend,

> 3) When a JComponent needs an UI, it asks it to the UIManager but it
> used its class loader, not the LookAndFeel class loader. And the
> JComponent class loader is often local so it can not find the UI class.
> I think this is a registered bug and I don't know on which JDK is
> applied. A work-around is to register the classloader into the
> UIDefaults and eventually to preload the UI classes:
>
>     ClassLoader cl=renderer_class.getClassLoader();
>     Hashtable   tb=UIManager.getDefaults();
>
>     // regsiter the classloader
>     tb.put("ClassLoader",cl);
>
>     // preload
>     Enumeration e=tb.keys();
>     while(e.hasMoreElements())
>     {
>       String k=(String)e.nextElement();
>
>       if(k.endsWith("UI"))
>       {
>       Class uic=cl.loadClass((String)tb.get(k));
>       tb.put(uic.getName(),uic);
>       }
>     }

I tested your work around and it worked fine for me :) Of course I bypassed
the "preload" section. When I took a look at UIManager and UIDefaults source
code, I found out that it's not neccessary. Registering my own classloader
is enough.
Here is what I did exactly :

    LookAndFeel lnf =
(LookAndFeel)loadObjectFromResource("com.memoire.slaf.SlafLookAndFeel",
"slaf.zip");

        UIManager.getDefaults().put("ClassLoader",
lnf.getClass().getClassLoader());
        UIManager.setLookAndFeel(lnf);
        SwingUtilities.updateComponentTreeUI(this);

Thanks a million,
Armond


_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing

Reply via email to