Hi,
Armond Avanes wrote:
> I'm just having some problem with LnFs! The scenario is that I want to load
> my application's look&feels dynamically. On the other hand I don't want to
> put the LnF jar/zip files in the classpath. So the first solution everyone
> may think of is to use URLClassLoader! I'm also doing so.
> L&F-Name="Slaf" L&F-Package="com.memoire.slaf.SlafLookAndFeel"
> L&F-Resource="slaf.zip"
Andrew Palumbo wrote:
> I haven't done swing or runtime linking in a while, but I think
> what happened is that you didn't load the rest of the Look and Feel
> classes... Since the jar isn't in the classpath, things like the L&F's
> JPanel replacement need to be linked explicitly, as well...
> Sorry I can't be more explicit, right now, in what you have to do, but
> hopefully this has helped somewhat.
I think Andrew is right: UI classes are not retrieved. But there can be
many reasons.
1) I don't think it is your case, but JDK1.2.0 can use swing lnf only if
they are in the bootclasspath. Fortunately it doesn't concern JDK1.1 nor
JDK1.2.2 and JDK1.3.
2) The UI classes are (in many LNFs) registrered by their string names
in the UIDefaults Hashtable. It means that there is no reference to the
UI classes in the LookAndFeel class. So they are not downloaded neither
resolved.
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);
}
}
Maybe there is something to do with the resources also.
Hope it helps. Tell me if there is something to patch in Slaf.
Regards, Guillaume Desnoix
--
Author of SLAF, the simple look and feel
http://www.memoire.com/guillaume-desnoix/slaf/
(new release and themes soon available)
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing