我用abbot软件测试gui界面的时候,在进入界面后抛出异常。怎么解决。也没有办法测试;
异常如下。
UIDefaults.getUI() failed: no ComponentUI class for: net.lancetech.ioffice.client.login.UserButton[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=null,paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=,defaultCapable=true]
java.lang.Error
at javax.swing.UIDefaults.getUIError(Unknown Source)
at javax.swing.MultiUIDefaults.getUIError(Unknown Source)
at javax.swing.UIDefaults.getUI(Unknown Source)
at javax.swing.UIManager.getUI(Unknown Source)
at com.jidesoft.swing.JideButton.updateUI(Unknown Source)
at javax.swing.AbstractButton.init(Unknown Source)
at javax.swing.JButton.<init>(Unknown Source)
at javax.swing.JButton.<init>(Unknown Source)
at com.jidesoft.swing.JideButton.<init>(Unknown Source)
at com.jidesoft.swing.JideButton.<init>(Unknown Source)
at net.lancetech.ioffice.client.login.UserButton.<init>(UserButton.java:25)
at net.lancetech.ioffice.client.login.Login.addButton(Login.java:256)
at net.lancetech.ioffice.client.login.Login.initUserSelectionBar(Login.java:216)
at net.lancetech.ioffice.client.login.Login.getUserSelectionPanel(Login.java:230)
at net.lancetech.ioffice.client.login.Login.initCenterPanel(Login.java:199)
at net.lancetech.ioffice.client.login.Login.initComponents(Login.java:171)
at net.lancetech.ioffice.client.login.Login.<init>(Login.java:108)
at net.lancetech.ioffice.client.login.Login.main(Login.java:115)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at abbot.script.Call.invoke(Call.java:194)
at abbot.script.Call.runStep(Call.java:129)
at abbot.script.Launch.synchronizedRunStep(Launch.java:138)
at abbot.script.Launch.runStep(Launch.java:203)
at abbot.script.Step.run(Step.java:93)
at abbot.script.StepRunner.runStep(StepRunner.java:274)
at abbot.script.Sequence.runStep(Sequence.java:110)
at abbot.script.Script.runStep(Script.java:501)
at abbot.script.StepRunner.runStep(StepRunner.java:271)
at abbot.script.StepRunner.run(StepRunner.java:191)
at abbot.editor.ScriptEditor$LaunchAction.run(ScriptEditor.java:2616)
at java.lang.Thread.run(Unknown Source)

解决方案 »

  1.   

    有外国人是这么改的。
    After a little break I came back to this and found that the problem 
    isn't to do with class loaders but instead with the 
    "LookAndFeelPreserver" class, it appears that the sequence of events is 
    as follows:1. JDeveloper Starts
    2. JDeveloper set our custom look and feel. (UIDefaults now has 730 entries)
    3. JDeveloper adds a few new properties to UIDefaults. (UIDefaults now 
    has 736 entries)
    4. At some point later the LookAndFeelPreserver stored the JDeveloper 
    look and feel, swaps to its preferred look and feel, then back to the 
    stored JDeveloper look and feel. Critically the modification to 
    UIDefaults are lost because of this. (UIDefaults now has 730 entries)
    5. JDeveloper tries to create UI component and fails.I commented out that code in LookAndFeelPreserver and JDeveloper will 
    now start and I can record sequences in Costello. I suppose an option 
    would be to to provide a preference to disable this class; but I wonder 
    if there is a better solution to this problem? Perhaps defining a new 
    sun.awt.AppContext for each running script perhaps... do you have any 
    thoughts on this?
    但是我十分的不明白。求一个解释。
      

  2.   

    LookAndFeelPreserver 的类代码如下。要注释掉的是哪几行??package abbot.editor;import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;import abbot.Log;
    import abbot.util.*;/** Preserves the current LAF for a given component hierarchy. */
    public class LookAndFeelPreserver {
        private LookAndFeel laf;
        private Map owned = new WeakHashMap();
        /** Avoid GC of weak reference. */ 
        private AWTEventListener listener;    private Frame frame;
        /** This panel detects any global attempts to set the UI for all
            components.  It can then restore the proper LAF for all registered
            components.  We use this pseudo-listener instead of listening to a
            "lookAndFeel" property change since the UI components may have
            updateUI called an arbitrary time (or not at all) after
            UIManager.setLookAndFeel is called (which triggers the property change
            notification). 
        */
        private JPanel trigger;    public LookAndFeelPreserver(Component c) {
            this(UIManager.getLookAndFeel(), c);
        }
        
        public LookAndFeelPreserver(final LookAndFeel laf, Component c) {
            this.laf = laf;
            add(c);
            listener = new AWTEventListener() {
                public void eventDispatched(AWTEvent e) {
                    if (e.getID() == ContainerEvent.COMPONENT_ADDED) {
                        componentAdded(((ContainerEvent)e).getChild());
                    }
                }
            };
            new WeakAWTEventListener(listener, AWTEvent.CONTAINER_EVENT_MASK);
            String name = "updateComponentTreeUI Listener";
            frame = new Frame(name);
            frame.setName(name);
            trigger = new JPanel() {
                private boolean initialized;
                { initialized = true; }
                public void updateUI() {
                    if (initialized) {
                        SwingUtilities.invokeLater(new LAFRestorer(laf, owned));
                    }
                }
            };
            frame.add(trigger);
        }    /** Add a component on which to preserve the LAF. */
        public void add(final Component c) {
            owned.put(c, Boolean.TRUE);
            if (c instanceof Window) {
                Window[] subs = ((Window)c).getOwnedWindows();
                for (int i=0;i < subs.length;i++) {
                    add(subs[i]);
                }
            }
        }    private void componentAdded(Component c) {
            Window w = AWT.getWindow(c);
            if (w != null) {
                if (owned.containsKey(w)
                    || owned.containsKey(w.getParent())) {
                    if (!owned.containsKey(w))
                        add(w);
                    SwingUtilities.invokeLater(new LAFRestorer(laf, c));
                }
            }
        }    private static class LAFRestorer implements Runnable {
            private LookAndFeel laf;
            private Map map;
            public LAFRestorer(LookAndFeel laf, Component c) {
                this(laf, new WeakHashMap());
                map.put(c, Boolean.TRUE);
            }
            public LAFRestorer(LookAndFeel laf, Map map) {
                this.laf = laf;
                this.map = map;
            }
            public void run() {
                LookAndFeel current = UIManager.getLookAndFeel();
                if (current != laf 
                    && current != null && !current.equals(laf)) {
                    try {
                        UIManager.setLookAndFeel(laf);
                        Iterator iter = map.keySet().iterator();
                        while (iter.hasNext()) {
                            Component c = (Component)iter.next();
                            SwingUtilities.updateComponentTreeUI(c);
                        }
                        UIManager.setLookAndFeel(current);
                    }
                    catch(UnsupportedLookAndFeelException e) {
                        // ignore
                    }
                }
            }
        }
    }