Hi Gurus,

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. Here is the L&F
list (which can be found in app configuration file) :

L&F-Name="MacOS"
L&F-Package="it.unitn.ing.swing.plaf.macos.MacOSLookAndFeel"
L&F-Resource="macos.jar"
L&F-Name="Slaf"   L&F-Package="com.memoire.slaf.SlafLookAndFeel"
L&F-Resource="slaf.zip"
...

And here is my code for loading and applying L&Fs :

        public void justATestMethod()
        {
        LookAndFeel lnf =
(LookAndFeel)loadObjectFromResource("it.unitn.ing.swing.plaf.macos.MacOSLook
AndFeel", "macos.jar");

                UIManager.setLookAndFeel(lnf);
                SwingUtilities.updateComponentTreeUI(this);
        }

        private Object loadObjectFromResource(String class_name, String resource)
throws Exception
        {
        LinkedList url_list = new LinkedList();
        StringTokenizer tokenizer = new StringTokenizer(resource, ",;");

                while( tokenizer.hasMoreTokens() )
                {
                        try
                        {
                                url_list.add( new File(tokenizer.nextToken()).toURL() 
);
                        }
                        catch( Exception e )
                        {
                                e.printStackTrace();
                        }
                }

        URL[] urls = (URL[])url_list.toArray(new URL[url_list.size()]);
        ClassLoader class_loader = new URLClassLoader(urls);
        Class renderer_class = Class.forName(class_name, true, class_loader);

                return renderer_class.newInstance();
        }

It seems that 'LookAndFeel' object is loaded successfully (it's not null
when i print it!) but when it's applied by  "UIManager.setLookAndFeel(..)",
I get a bunch of exceptions like :

UIDefaults.getUI() failed: no ComponentUI class for:
javax.swing.JPanel[null.contentPane,0,0,456x348,layout=java.awt.GridBagLayou
t,alignmentX=null,alignmentY=null,border=,flags=34,maximumSize=,minimumSize=
,preferredSize=,defaultLayout=java.awt.FlowLayout[hgap=5,vgap=5,align=center
]]
java.lang.Error
        at javax.swing.UIDefaults.getUIError(UIDefaults.java:392)
        at javax.swing.UIDefaults.getUI(UIDefaults.java:422)
        at javax.swing.UIManager.getUI(UIManager.java:566)
        at javax.swing.JPanel.updateUI(JPanel.java:107)
        at
javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1094)
        at
javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1105)
        at
javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1105)
        at
javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1105)
        at
javax.swing.SwingUtilities.updateComponentTreeUI(SwingUtilities.java:1086)
........

UIDefaults.getUI() failed: no ComponentUI class for:
javax.swing.JLabel[,5,8,101x17,alignmentX=0.0,alignmentY=null,border=,flags=
1664,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,hor
izontalAlignment=,horizontalTextPosition=,iconTextGap=4,labelFor=,text=Name:
,verticalAlignment=CENTER,verticalTextPosition=CENTER]
java.lang.Error
        at javax.swing.UIDefaults.getUIError(UIDefaults.java:392)
        at javax.swing.UIDefaults.getUI(UIDefaults.java:422)
        at javax.swing.UIManager.getUI(UIManager.java:566)
        at javax.swing.JLabel.updateUI(JLabel.java:247)
        at
javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1094)
        at
javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1105)
        at
javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1105)
        at
javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1105)
        at
javax.swing.SwingUtilities.updateComponentTreeUI0(SwingUtilities.java:1105)
        at
javax.swing.SwingUtilities.updateComponentTreeUI(SwingUtilities.java:1086)
........

I have a 4MB log of these exceptions!!
Does anyone know what the problem can be ? Am I missing something in my code
?
Any suggestions ? Comment ? Any Clue ?

Best Regards,
Armond


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

Reply via email to