Paul,
I think this is a class loader problem rather that a PLAF specific problem.
The javax.swing classes are included in rt.jar and so will be loaded by the
bootstrap class loader. Classes in your application are not visible to the
bootstrap class loader. I can think of two solutions to this:
1) Jar up the classes you want to be lazily loaded and pass in the jar using
the -Xbootclasspath/a:path option. This should make your classes visible to
the bootstrap class loader.
2) Subclass UIDefaults.LazyValue so that createValue does your own lazy
loading. This way you get many instances of your subclass of
UIDefaults.LazyValue instead of many instances of UIDefaults.ProxyLazyValue,
and you still get the lazy loading.
(There is actually option 3: move the javax.swing classes out of rt.jar but
I suspect that would be a breach of the licence.)
Regards
Dave Wathen
Goldman Sachs Asset Management
3rd Floor, Procession House
55 Ludgate Hill
London EC4M 7JN
+44 (0)20-7774-2998
It is not necessary to understand things in order to argue about them.
(Caron de Beaumarchais)
-----Original Message-----
From: Farwell, Paul [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 23, 2001 6:45 PM
To: '[EMAIL PROTECTED]'
Subject: problem with UIDefaults.ProxyLazyValue
Here's a question for a Look and Feel guru out there. Can I use
ProxyLazyValue to call my own methods? It appears to work only when loading
classes from core JDK packages.
Our application does a fair amount of initialization of UIDefaults when it
launches. Only a subset of the UI components are used by any individual
applet, so I want to load resources in a 'lazy' way, in the same way that
BasicLookAndFeel and MetalLookAndFeel do. I borrowed the following code from
these classes.
package com.kronos.wfc.wfp.uiframework;
public class GUIResources {
public static void installLookAndFeel() {
// Create a ProxyLazyValue for a tree icon:
Object treeExpandIcon = new UIDefaults.ProxyLazyValue(
"com.kronos.wfc.wfp.uiframework.GUIResources",
"getLazyExpandIcon");
Object[] settings = {
// ...
// lazily load the tree icons since the tree is not
// used in most applets
"Tree.expandedIcon", treeExpandIcon,
"Tree.selectionBackground", selectionBackground,
// etc.
};
UIDefaults defaults = UIManager.getDefaults();
defaults.putDefaults(settings);
}
// this method should be called 'lazily':
public static Object getLazyExpandIcon() {
System.out.println("Lazy request Exand image ");
return getImage("/demoimages/minus.gif");
}
}
It appears that the classloader cannot locate the class
("com.kronos.wfc.wfp.uiframework.GUIResources") with the lazy method. I have
tripled check that the classname has been provided correctly.
Any Idea what the problem is?
(BTW - Using UIDefaults.LazyValue() DOES work, but that approach causes the
creation of so many inner classes that it defeats the purpose of the
optimization).
Problem creating com.kronos.wfc.wfp.uiframework.GUIResources with method
getLazyExpandIcon and args { : java.lang.ClassNotFoundException:
com/kronos/wfc/wfp/uiframework/GUIResources
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:993)
at
javax.swing.UIDefaults$ProxyLazyValue.createValue(UIDefaults.java:670)
at javax.swing.UIDefaults.get(UIDefaults.java:145)
at javax.swing.MultiUIDefaults.get(MultiUIDefaults.java:39)
at javax.swing.UIManager.get(UIManager.java:536)
at
javax.swing.plaf.basic.BasicTreeUI.installDefaults(BasicTreeUI.java:593)
at
javax.swing.plaf.basic.BasicTreeUI.installUI(BasicTreeUI.java:525)
at javax.swing.plaf.metal.MetalTreeUI.installUI(MetalTreeUI.java:83)
at javax.swing.JComponent.setUI(JComponent.java:325)
at javax.swing.JTree.setUI(JTree.java:537)
at javax.swing.JTree.updateUI(JTree.java:553)
at javax.swing.JTree.<init>(JTree.java:513)
at
com.kronos.wfc.wfp.uiframework.component.KronosTree.<init>(KronosTree.java:1
87)
at
com.kronos.wfc.applets.appletdemo.DemoTreePanel.init(DemoTreePanel.java:84)
at
com.kronos.wfc.applets.appletdemo.DemoTreePanel.<init>(DemoTreePanel.java:35
)
at
com.kronos.wfc.applets.appletdemo.SimpleRootPanel.createInitialDisplay(Simpl
eRootPanel.java:46)
at
com.kronos.wfc.applets.appletdemo.SimpleRootPanel.<init>(SimpleRootPanel.jav
a:21)
at
com.kronos.wfc.applets.appletdemo.SimpleApplet.onLoad(SimpleApplet.java:13)
at
com.kronos.wfc.wfp.uiframework.baseapplet.KronosApplet.runBackgroundTask(Kro
nosApplet.java:450)
at
com.kronos.wfc.wfp.uiframework.utility.BuilderThread.run(BuilderThread.java:
73)
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing