2 andy zjf Andy_zjf 于 2015.07.16 17:28 提问

执行到 NativeInterface.runEventPump 页面卡死

最近公司要做一个C/S架构的系统,需要一个swing的浏览器,在网上找到了一段代码,不明白单独运行打开的时候没有问题,但是将浏览器绑定到一个组件上,点击组件打开就页面卡死,不会动了,求指教,代码如下:
Swing浏览器:

import java.awt.BorderLayout;

import javax.swing.JFrame;  
import javax.swing.JPanel;  
import javax.swing.JScrollPane;  
import javax.swing.ScrollPaneConstants;  
import javax.swing.SwingUtilities;  

import chrriis.common.UIUtils;  
import chrriis.dj.nativeswing.swtimpl.NativeInterface;  
import chrriis.dj.nativeswing.swtimpl.components.JWebBrowser;  

public class ReportPreviewUtil extends JPanel {  

    private static final long serialVersionUID = 1L; 

    private static ReportPreviewUtil reportPreviewUtil ;

    static String name ;

    static String URL ;

    public static ReportPreviewUtil getInstance(String title,String url){
        name = title;
        URL = url ;
        if(null == reportPreviewUtil){
            reportPreviewUtil = new ReportPreviewUtil();
        }
        return reportPreviewUtil ;
    }

    static String url ;

    public ReportPreviewUtil() {  

        super(new BorderLayout());  
        JScrollPane webBrowserPanel = new JScrollPane();  
        webBrowserPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);  
        final JWebBrowser webBrowser = new JWebBrowser();  

        webBrowser.setBarsVisible(false);  
        webBrowser.navigate(URL);  
        add(webBrowser, BorderLayout.CENTER);  
    }  

    public static void get() {  
        UIUtils.setPreferredLookAndFeel();  
        NativeInterface.open();  
        SwingUtilities.invokeLater(new Runnable() {  
            public void run() {  
                JFrame frame = new JFrame(name);  
                frame.setUndecorated(true);// 禁用此窗体的装饰  
                frame.setLocationRelativeTo(null);//居中显示  
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
                frame.getContentPane().add(new ReportPreviewUtil(), BorderLayout.CENTER);  

                frame.setSize(938, 614);  

                frame.setLocationByPlatform(true);  
                frame.setVisible(true);                  
            }  
        });  
        NativeInterface.runEventPump();  
    }  

    public static void main(String[] args) {
        ReportPreviewUtil.getInstance("", "http://www.baidu.com").get();
    }
}  

按钮组件绑定后,调用:

 private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
        ReportPreviewUtil.getInstance("", "http://www.baidu.com").get();
    }

在ReportPreviewUtil中的main方法运行正常,通过按钮执行就页面卡死,为什么呢?

5个回答

CSDNXIAON
CSDNXIAON   2015.07.16 17:32

SwingUtilities的invokeLater和invokeAndWait
java学习之路6-SwingUtilities中invokeLater和invokeAndWait
----------------------同志你好,我是CSDN问答机器人小N,奉组织之命为你提供参考答案,编程尚未成功,同志仍需努力!

shangyue1110
shangyue1110   2015.07.16 17:55

阻塞执行了 我之前碰到类似的问题 导致 界面阻塞 一直加载不出来~~
然后就直接开线程 去处理了~写了一个继承Thread的内部类,
然后里面处理业务逻辑,你再在invokeLater里面 实例化这个线程并start~~
貌似可以解决~

tongyi55555
tongyi55555   2015.07.16 19:49

SWING是单线程的,你还是将get方法中的内容用thread包一下就可以了。如下:

new Thread(){
            @Override
            public void run() {
 UIUtils.setPreferredLookAndFeel();  
        NativeInterface.open();  
        SwingUtilities.invokeLater(new Runnable() {  
            public void run() {  
                JFrame frame = new JFrame(name);  
                frame.setUndecorated(true);// 禁用此窗体的装饰  
                frame.setLocationRelativeTo(null);//居中显示  
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
                frame.getContentPane().add(new ReportPreviewUtil(), BorderLayout.CENTER);  

                frame.setSize(938, 614);  

                frame.setLocationByPlatform(true);  
                frame.setVisible(true);                  
            }  
        });  
        NativeInterface.runEventPump();  
                }
        }.start();
Andy_zjf
Andy_zjf   2015.07.17 17:28

感谢 @Varlinor,@那一抹代码 但是这个方法我也试过了,不行,会报一下错误:

    at sun.reflect.DelegatingMethodAccessorImpl.invoke

(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:771)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JToolBar.updateUI(JToolBar.java:192)
    at javax.swing.JToolBar.<init>(JToolBar.java:158)
    at javax.swing.JToolBar.<init>(JToolBar.java:119)
    at javax.swing.JToolBar.<init>(JToolBar.java:107)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator

$WebBrowserButtonBar.<init>(DefaultWebBrowserDecorator.java:371)
    at 

chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.setButtonBarVisible

(DefaultWebBrowserDecorator.java:667)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>

(DefaultWebBrowserDecorator.java:573)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator

(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>

(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run

(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
UIDefaults.getUI() failed: createUI() failed for 

chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator$WebBrowserButtonBar

[,0,0,0x0,invalid,layout=javax.swing.JToolBar

$DefaultToolBarLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSiz

e=,preferredSize=,floatable=true,margin=,orientation=HORIZONTAL,paintBorder=true] 

java.lang.reflect.InvocationTargetException
java.lang.Error
    at javax.swing.UIDefaults.getUIError(UIDefaults.java:732)
    at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:777)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JToolBar.updateUI(JToolBar.java:192)
    at javax.swing.JToolBar.<init>(JToolBar.java:158)
    at javax.swing.JToolBar.<init>(JToolBar.java:119)
    at javax.swing.JToolBar.<init>(JToolBar.java:107)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator

$WebBrowserButtonBar.<init>(DefaultWebBrowserDecorator.java:371)
    at 

chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.setButtonBarVisible

(DefaultWebBrowserDecorator.java:667)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>

(DefaultWebBrowserDecorator.java:573)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator

(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>

(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run

(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
org.jvnet.substance.api.UiThreadingViolationException: Component creation must be done on 

Event Dispatch Thread
    at 

org.jvnet.substance.utils.SubstanceCoreUtilities.testComponentCreationThreadingViolation

(SubstanceCoreUtilities.java:2368)
    at org.jvnet.substance.SubstanceButtonUI.createUI(SubstanceButtonUI.java:122)
    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke

(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke

(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:771)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JButton.updateUI(JButton.java:146)
    at javax.swing.AbstractButton.init(AbstractButton.java:2172)
    at javax.swing.JButton.<init>(JButton.java:136)
    at javax.swing.JButton.<init>(JButton.java:90)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator

$WebBrowserButtonBar.<init>(DefaultWebBrowserDecorator.java:373)
    at 

chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.setButtonBarVisible

(DefaultWebBrowserDecorator.java:667)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>

(DefaultWebBrowserDecorator.java:573)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator

(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>

(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run

(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
UIDefaults.getUI() failed: createUI() failed for javax.swing.JButton

[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,p

referredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=null,paintBorder=true

,paintFocus=true,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,sel

ectedIcon=,text=,defaultCapable=true] java.lang.reflect.InvocationTargetException
java.lang.Error
    at javax.swing.UIDefaults.getUIError(UIDefaults.java:732)
    at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:777)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JButton.updateUI(JButton.java:146)
    at javax.swing.AbstractButton.init(AbstractButton.java:2172)
    at javax.swing.JButton.<init>(JButton.java:136)
    at javax.swing.JButton.<init>(JButton.java:90)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator

$WebBrowserButtonBar.<init>(DefaultWebBrowserDecorator.java:373)
    at 

chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.setButtonBarVisible

(DefaultWebBrowserDecorator.java:667)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>

(DefaultWebBrowserDecorator.java:573)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator

(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>

(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run

(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
org.jvnet.substance.api.UiThreadingViolationException: Component creation must be done on 

Event Dispatch Thread
    at 

org.jvnet.substance.utils.SubstanceCoreUtilities.testComponentCreationThreadingViolation

(SubstanceCoreUtilities.java:2368)
    at org.jvnet.substance.SubstanceButtonUI.createUI(SubstanceButtonUI.java:122)
    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke

(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke

(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:771)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JButton.updateUI(JButton.java:146)
    at javax.swing.AbstractButton.init(AbstractButton.java:2172)
    at javax.swing.JButton.<init>(JButton.java:136)
    at javax.swing.JButton.<init>(JButton.java:90)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator

$WebBrowserButtonBar.<init>(DefaultWebBrowserDecorator.java:382)
    at 

chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.setButtonBarVisible

(DefaultWebBrowserDecorator.java:667)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>

(DefaultWebBrowserDecorator.java:573)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator

(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>

(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run

(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
UIDefaults.getUI() failed: createUI() failed for javax.swing.JButton

[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,p

referredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=null,paintBorder=true

,paintFocus=true,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,sel

ectedIcon=,text=,defaultCapable=true] java.lang.reflect.InvocationTargetException
java.lang.Error
    at javax.swing.UIDefaults.getUIError(UIDefaults.java:732)
    at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:777)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JButton.updateUI(JButton.java:146)
    at javax.swing.AbstractButton.init(AbstractButton.java:2172)
    at javax.swing.JButton.<init>(JButton.java:136)
    at javax.swing.JButton.<init>(JButton.java:90)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator

$WebBrowserButtonBar.<init>(DefaultWebBrowserDecorator.java:382)
    at 

chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.setButtonBarVisible

(DefaultWebBrowserDecorator.java:667)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>

(DefaultWebBrowserDecorator.java:573)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator

(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>

(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run

(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
org.jvnet.substance.api.UiThreadingViolationException: Component creation must be done on 

Event Dispatch Thread
    at 

org.jvnet.substance.utils.SubstanceCoreUtilities.testComponentCreationThreadingViolation

(SubstanceCoreUtilities.java:2368)
    at org.jvnet.substance.SubstanceButtonUI.createUI(SubstanceButtonUI.java:122)
    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke

(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke

(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:771)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JButton.updateUI(JButton.java:146)
    at javax.swing.AbstractButton.init(AbstractButton.java:2172)
    at javax.swing.JButton.<init>(JButton.java:136)
    at javax.swing.JButton.<init>(JButton.java:90)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator

$WebBrowserButtonBar.<init>(DefaultWebBrowserDecorator.java:391)
    at 

chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.setButtonBarVisible

(DefaultWebBrowserDecorator.java:667)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>

(DefaultWebBrowserDecorator.java:573)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator

(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>

(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run

(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
UIDefaults.getUI() failed: createUI() failed for javax.swing.JButton

[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,p

referredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=null,paintBorder=true

,paintFocus=true,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,sel

ectedIcon=,text=,defaultCapable=true] java.lang.reflect.InvocationTargetException
java.lang.Error
    at javax.swing.UIDefaults.getUIError(UIDefaults.java:732)
    at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:777)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JButton.updateUI(JButton.java:146)
    at javax.swing.AbstractButton.init(AbstractButton.java:2172)
    at javax.swing.JButton.<init>(JButton.java:136)
    at javax.swing.JButton.<init>(JButton.java:90)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator

$WebBrowserButtonBar.<init>(DefaultWebBrowserDecorator.java:391)
    at 

chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.setButtonBarVisible

(DefaultWebBrowserDecorator.java:667)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>

(DefaultWebBrowserDecorator.java:573)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator

(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>

(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run

(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
org.jvnet.substance.api.UiThreadingViolationException: Component creation must be done on 

Event Dispatch Thread
    at 

org.jvnet.substance.utils.SubstanceCoreUtilities.testComponentCreationThreadingViolation

(SubstanceCoreUtilities.java:2368)
    at org.jvnet.substance.SubstanceButtonUI.createUI(SubstanceButtonUI.java:122)
    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke

(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke

(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:771)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JButton.updateUI(JButton.java:146)
    at javax.swing.AbstractButton.init(AbstractButton.java:2172)
    at javax.swing.JButton.<init>(JButton.java:136)
    at javax.swing.JButton.<init>(JButton.java:90)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator

$WebBrowserButtonBar.<init>(DefaultWebBrowserDecorator.java:399)
    at 

chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.setButtonBarVisible

(DefaultWebBrowserDecorator.java:667)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>

(DefaultWebBrowserDecorator.java:573)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator

(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>

Andy_zjf
Andy_zjf   2015.07.17 17:29

我找了下网上的资料,说是NativeInterface.runEventPump不支持并发。我尝试把NativeInterface.runEventPump();注释掉(我不明白这个代码什么意思),会报一下错误:

    at javax.swing.JMenu.ensurePopupMenuCreated(JMenu.java:545)
    at javax.swing.JMenu.add(JMenu.java:578)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator$WebBrowserMenuBar.<init>(DefaultWebBrowserDecorator.java:267)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>(DefaultWebBrowserDecorator.java:565)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
org.jvnet.substance.api.UiThreadingViolationException: Component creation must be done on Event Dispatch Thread
    at org.jvnet.substance.utils.SubstanceCoreUtilities.testComponentCreationThreadingViolation(SubstanceCoreUtilities.java:2368)
    at org.jvnet.substance.SubstanceCheckBoxMenuItemUI.createUI(SubstanceCheckBoxMenuItemUI.java:82)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:771)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JMenuItem.updateUI(JMenuItem.java:249)
    at javax.swing.JMenuItem.init(JMenuItem.java:211)
    at javax.swing.JMenuItem.<init>(JMenuItem.java:150)
    at javax.swing.JCheckBoxMenuItem.<init>(JCheckBoxMenuItem.java:164)
    at javax.swing.JCheckBoxMenuItem.<init>(JCheckBoxMenuItem.java:104)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator$WebBrowserMenuBar.<init>(DefaultWebBrowserDecorator.java:268)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>(DefaultWebBrowserDecorator.java:565)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
UIDefaults.getUI() failed: createUI() failed for javax.swing.JCheckBoxMenuItem[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=null,paintBorder=false,paintFocus=false,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=] java.lang.reflect.InvocationTargetException
java.lang.Error
    at javax.swing.UIDefaults.getUIError(UIDefaults.java:732)
    at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:777)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JMenuItem.updateUI(JMenuItem.java:249)
    at javax.swing.JMenuItem.init(JMenuItem.java:211)
    at javax.swing.JMenuItem.<init>(JMenuItem.java:150)
    at javax.swing.JCheckBoxMenuItem.<init>(JCheckBoxMenuItem.java:164)
    at javax.swing.JCheckBoxMenuItem.<init>(JCheckBoxMenuItem.java:104)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator$WebBrowserMenuBar.<init>(DefaultWebBrowserDecorator.java:268)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>(DefaultWebBrowserDecorator.java:565)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
org.jvnet.substance.api.UiThreadingViolationException: Component creation must be done on Event Dispatch Thread
    at org.jvnet.substance.utils.SubstanceCoreUtilities.testComponentCreationThreadingViolation(SubstanceCoreUtilities.java:2368)
    at org.jvnet.substance.SubstancePopupMenuUI.createUI(SubstancePopupMenuUI.java:59)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:771)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JPopupMenu.updateUI(JPopupMenu.java:227)
    at javax.swing.JPopupMenu.<init>(JPopupMenu.java:192)
    at javax.swing.JPopupMenu.<init>(JPopupMenu.java:177)
    at javax.swing.JMenu.ensurePopupMenuCreated(JMenu.java:545)
    at javax.swing.JMenu.add(JMenu.java:578)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator$WebBrowserMenuBar.<init>(DefaultWebBrowserDecorator.java:277)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>(DefaultWebBrowserDecorator.java:565)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
UIDefaults.getUI() failed: createUI() failed for javax.swing.JPopupMenu[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,desiredLocationX=0,desiredLocationY=0,label=,lightWeightPopupEnabled=true,margin=,paintBorder=true] java.lang.reflect.InvocationTargetException
java.lang.Error
    at javax.swing.UIDefaults.getUIError(UIDefaults.java:732)
    at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:777)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JPopupMenu.updateUI(JPopupMenu.java:227)
    at javax.swing.JPopupMenu.<init>(JPopupMenu.java:192)
    at javax.swing.JPopupMenu.<init>(JPopupMenu.java:177)
    at javax.swing.JMenu.ensurePopupMenuCreated(JMenu.java:545)
    at javax.swing.JMenu.add(JMenu.java:578)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator$WebBrowserMenuBar.<init>(DefaultWebBrowserDecorator.java:277)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>(DefaultWebBrowserDecorator.java:565)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
org.jvnet.substance.api.UiThreadingViolationException: Component creation must be done on Event Dispatch Thread
    at org.jvnet.substance.utils.SubstanceCoreUtilities.testComponentCreationThreadingViolation(SubstanceCoreUtilities.java:2368)
    at org.jvnet.substance.SubstanceCheckBoxMenuItemUI.createUI(SubstanceCheckBoxMenuItemUI.java:82)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:771)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JMenuItem.updateUI(JMenuItem.java:249)
    at javax.swing.JMenuItem.init(JMenuItem.java:211)
    at javax.swing.JMenuItem.<init>(JMenuItem.java:150)
    at javax.swing.JCheckBoxMenuItem.<init>(JCheckBoxMenuItem.java:164)
    at javax.swing.JCheckBoxMenuItem.<init>(JCheckBoxMenuItem.java:104)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator$WebBrowserMenuBar.<init>(DefaultWebBrowserDecorator.java:278)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>(DefaultWebBrowserDecorator.java:565)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
UIDefaults.getUI() failed: createUI() failed for javax.swing.JCheckBoxMenuItem[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=null,paintBorder=false,paintFocus=false,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=] java.lang.reflect.InvocationTargetException
java.lang.Error
    at javax.swing.UIDefaults.getUIError(UIDefaults.java:732)
    at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:777)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JMenuItem.updateUI(JMenuItem.java:249)
    at javax.swing.JMenuItem.init(JMenuItem.java:211)
    at javax.swing.JMenuItem.<init>(JMenuItem.java:150)
    at javax.swing.JCheckBoxMenuItem.<init>(JCheckBoxMenuItem.java:164)
    at javax.swing.JCheckBoxMenuItem.<init>(JCheckBoxMenuItem.java:104)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator$WebBrowserMenuBar.<init>(DefaultWebBrowserDecorator.java:278)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>(DefaultWebBrowserDecorator.java:565)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
org.jvnet.substance.api.UiThreadingViolationException: Component creation must be done on Event Dispatch Thread
    at org.jvnet.substance.utils.SubstanceCoreUtilities.testComponentCreationThreadingViolation(SubstanceCoreUtilities.java:2368)
    at org.jvnet.substance.SubstancePopupMenuSeparatorUI.createUI(SubstancePopupMenuSeparatorUI.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:771)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JSeparator.updateUI(JSeparator.java:139)
    at javax.swing.JSeparator.<init>(JSeparator.java:106)
    at javax.swing.JPopupMenu$Separator.<init>(JPopupMenu.java:1526)
    at javax.swing.JPopupMenu.addSeparator(JPopupMenu.java:552)
    at javax.swing.JMenu.addSeparator(JMenu.java:674)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator$WebBrowserMenuBar.<init>(DefaultWebBrowserDecorator.java:287)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>(DefaultWebBrowserDecorator.java:565)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
UIDefaults.getUI() failed: createUI() failed for javax.swing.JPopupMenu$Separator[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,orientation=HORIZONTAL] java.lang.reflect.InvocationTargetException
java.lang.Error
    at javax.swing.UIDefaults.getUIError(UIDefaults.java:732)
    at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
    at javax.swing.UIDefaults.getUI(UIDefaults.java:777)
    at javax.swing.UIManager.getUI(UIManager.java:1013)
    at javax.swing.JSeparator.updateUI(JSeparator.java:139)
    at javax.swing.JSeparator.<init>(JSeparator.java:106)
    at javax.swing.JPopupMenu$Separator.<init>(JPopupMenu.java:1526)
    at javax.swing.JPopupMenu.addSeparator(JPopupMenu.java:552)
    at javax.swing.JMenu.addSeparator(JMenu.java:674)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator$WebBrowserMenuBar.<init>(DefaultWebBrowserDecorator.java:287)
    at chrriis.dj.nativeswing.swtimpl.components.DefaultWebBrowserDecorator.<init>(DefaultWebBrowserDecorator.java:565)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.createWebBrowserDecorator(JWebBrowser.java:112)
    at chrriis.dj.nativeswing.swtimpl.components.JWebBrowser.<init>(JWebBrowser.java:191)
    at com.lida.util.ReportPreviewUtil.<init>(ReportPreviewUtil.java:45)
    at com.lida.util.ReportPreviewUtil.getInstance(ReportPreviewUtil.java:32)
    at com.lida.main.branch.report.dailyschedule.thread.DailyScheduleReportThread.run(DailyScheduleReportThread.java:10)
    at java.lang.Thread.run(Thread.java:745)
Csdn user default icon
上传中...
上传图片
插入图片