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

Reply via email to