Java-JFXpanel刷新页面导致JVM崩溃 - 线程问题

时间:2014-06-13 14:54:03

标签: java swing javafx

我尝试使用here 中的教程

将JavaFX面板嵌入到Java Swing中

我使用的是java 8 update 20,JavaFX 2.0或2.2(不太确定如何检查)

这是我的代码:

JavaFX代码:

public class SwingFXWebView{  

    public final JFXPanel jfxpanel;

    public SwingFXWebView(String[] para, int width, int height){  
        jfxpanel = new JFXPanel();
        jfxpanel.setLayout(new BorderLayout());

        //add(jfxpanel, BorderLayout.CENTER);
        Platform.runLater( new Runnable(){
            public void run(){
                initFX(jfxpanel);
            }
        });
    }


    private static void initFX(JFXPanel jfxpanel){
        Scene scene = createScene();
        jfxpanel.setScene(scene);
    }


    private static Scene createScene() {
        Platform.setImplicitExit(false);
        Group  root  =  new  Group();
        final Scene  scene  =  new  Scene(root, Color.ALICEBLUE);
        WebView browser;

        browser = new WebView();
     //browser.setContextMenuEnabled(false);
        browser.autosize();
        WebEngine webEngine = browser.getEngine();
        webEngine.load("www.google.ca");

        root.getChildren().add(browser); 
        return (scene);
   } 

Swing代码:

SwingUtilities.invokeLater(new Runnable() {
    public void run() {  
    //Jdesktop browser
        sfwv = new SwingFXWebView(para, panelContents.getWidth(),panelContents.getHeight());
        panelContents.add(sfwv.jfxpanel, BorderLayout.CENTER);

....
}

它到目前为止有效。如果我鼠标右键单击以刷新页面并第二次执行此操作,则JVM会崩溃。

A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000005c2728e0, pid=5376, tid=5084
#

它看起来像线程问题,但我严格遵循oracle的教程。知道我做错了吗?

提前致谢!

0 个答案:

没有答案