简体   繁体   English

JavaFx 中的 jxBrowser - 线程“JavaFX 应用程序线程”中的异常 java.lang.IllegalStateException:无法获取本机 Z05B8C74CBD96FBF2DE4C1A352702FFF4Z 句柄

[英]jxBrowser in JavaFx - Exception in thread “JavaFX Application Thread” java.lang.IllegalStateException: Failed to get native window handle

I just tried to add a the jxBrowser to my jfx application,我只是尝试将 jxBrowser 添加到我的 jfx 应用程序中,

this is my object:这是我的 object:

class fxBrowserPane extends MyPane{

private Button _go;
private TextField _addr;
private HBox _bar;
private BorderPane _bp;

private BrowserView _nodevW;
private  Browser _browser;
private String url;

public fxBrowserPane(JSONObject json){
    super(json);
    url =  jsonobj.getString("url"); //url is https://www.google.com
    node = new AnchorPane();
    
    _bp = new BorderPane();
    _bar = new HBox(); //pannello con la barra degli indirizzi
    _go = new Button();
    _go.setText("GO");
    _addr = new TextField();
    _bar.setMaxWidth(Double.MAX_VALUE);
    _addr.setMaxWidth(Double.MAX_VALUE);
    _bar.getChildren().addAll(_addr,_go);
    HBox.setHgrow(_addr, Priority.ALWAYS);
    _bar.setPadding(new Insets(1));
    _bar.setAlignment(Pos.BASELINE_CENTER);
    _bp.setTop(_bar);    
}

//this is my start method:

public int start(){
   Engine engine = Engine.newInstance(
            EngineOptions.newBuilder(HARDWARE_ACCELERATED).enableIncognito().build());
    _browser = engine.newBrowser();
    _browser.navigation().loadUrl(url);
    _nodevW = BrowserView.newInstance(_browser);

    if (url != null) {
        _addr.setText(url);
        (_browser).navigation().loadUrl(url);
        System.err.println("load URL:"+url);
    }
    
    ((AnchorPane)node).getChildren().addAll(_bp);
    AnchorPane.setTopAnchor(_bp, 0.0);
    AnchorPane.setBottomAnchor(_bp, 0.0);
    AnchorPane.setLeftAnchor(_bp, 0.0);
    AnchorPane.setRightAnchor(_bp, 0.0);
    AnchorPane.setLeftAnchor(_bp, 0.0);
    AnchorPane.setRightAnchor(_bp, 0.0);
    _bp.setCenter(_nodevW);
    
    return 0;
  }
}

And this is the odd Exception I get:这是我得到的奇怪异常:

xception in thread "JavaFX Application Thread" java.lang.IllegalStateException: Failed to get native window handle
    at com.teamdev.jxbrowser.view.javafx.internal.Platform.lambda$nativeHandle$0(Platform.java:131)
    at java.base/java.util.Optional.orElseThrow(Optional.java:408)
    at com.teamdev.jxbrowser.view.javafx.internal.Platform.nativeHandle(Platform.java:131)
    at com.teamdev.jxbrowser.view.javafx.internal.WindowedWidget.attach(WindowedWidget.java:218)
    at com.teamdev.jxbrowser.view.javafx.internal.WindowedWidget.show(WindowedWidget.java:177)
    at com.teamdev.jxbrowser.view.javafx.internal.WindowedWidget.setWindow(WindowedWidget.java:319)
    at com.teamdev.jxbrowser.view.javafx.internal.WindowedWidget.access$1500(WindowedWidget.java:46)
    at com.teamdev.jxbrowser.view.javafx.internal.WindowedWidget$SceneChangeListener.setScene(WindowedWidget.java:496)
    at com.teamdev.jxbrowser.view.javafx.internal.WindowedWidget$SceneChangeListener.lambda$changed$0(WindowedWidget.java:478)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:834)

These are my vmargs:这些是我的 vmargs:

-classpath "D:\ECLIPSE_WORKSPACES\projectBrowser\lib\fxBrowser\lib\jxbrowser-7.13.jar;D:\ECLIPSE_WORKSPACES\projectBrowser\lib\fxBrowser\lib\jxbrowser-win32-7.13.jar;D:\ECLIPSE_WORKSPACES\projectBrowser\lib\fxBrowser\lib\jxbrowser-win64-7.13.jar;D:\ECLIPSE_WORKSPACES\projectBrowser\lib\fxBrowser\lib\jxbrowser-mac-7.13.jar;D:\ECLIPSE_WORKSPACES\projectBrowser\lib\fxBrowser\lib\jxbrowser-linux64-7.13.jar;D:\ECLIPSE_WORKSPACES\projectBrowser\lib\fxBrowser\lib\jxbrowser-linux64-arm-7.13.jar" -Djava.security.auth.login.config=resources/com/sitti/mfz/login/login.config --module-path "D:\Strumenti_di_sviluppo\openjfx-11.0.2_windows-x64_bin-sdk\javafx-sdk-11.0.2\lib"  --add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.web,javafx.swing --add-opens javafx.graphics/com.sun.glass.ui=ALL-UNNAMED --add-exports javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED --add-opens javafx.graphics/javafx.stage=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.tk.quantum=ALL-UNNAMED
public abstract class MyPane{
   protected string type;
   protected JSONObject conf;

   MyPane(JSONObject jobj){
     this.type = jobj.getString("type");
      this.conf = jobj;
}

 abstract int start();

}

Here they recommend to add more --add.exports :他们建议在这里添加更多--add.exports

In order to run JxBrowser under OpenJFX the following VM parameters must be applied at runtime:为了在 OpenJFX 下运行 JxBrowser,必须在运行时应用以下 VM 参数:

--add-exports javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.javafx.scene.traversal=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.glass.ui=ALL-UNNAMED
--add-exports java.desktop/sun.awt=ALL-UNNAMED

Although I must add that this did not solve it for me.尽管我必须补充一点,这并没有为我解决问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用JavaFX的多线程导致java.lang.IllegalStateException:不在FX应用程序线程上 - Multithreading with JavaFX causes java.lang.IllegalStateException: Not on FX application thread 线程“JavaFX 应用程序线程”中的异常 java.lang.IllegalStateException:一旦舞台设置为可见,就无法设置样式 - Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: Cannot set style once stage has been set visible 为什么我在 JavaFX 上收到 java.lang.IllegalStateException “Not on FX application thread”? - Why am I getting java.lang.IllegalStateException "Not on FX application thread" on JavaFX? 线程“ JavaFX应用程序线程” java.lang.IllegalArgumentException中的异常: - Exception in thread “JavaFX Application Thread” java.lang.IllegalArgumentException: 线程“ JavaFX应用程序线程” java.lang.NoClassDefFoundError中的异常 - Exception in thread “JavaFX Application Thread” java.lang.NoClassDefFoundError 线程“ JavaFX Application Thread”中的异常java.lang.IllegalArgumentException - Exception in thread “JavaFX Application Thread” java.lang.IllegalArgumentException 线程“ Thread-10”中的异常java.lang.IllegalStateException - Exception in thread “Thread-10” java.lang.IllegalStateException JavaFX:线程“ JavaFX Application Thread”中的异常java.lang.RuntimeException:java.lang.reflect.InvocationTargetException - JavaFX: Exception in thread “JavaFX Application Thread” java.lang.RuntimeException: java.lang.reflect.InvocationTargetException JavaFX:线程“ JavaFX Application Thread”中的异常java.lang.RuntimeException:java.lang.reflect.InvocationTargetException - JavaFX: Exception in thread “JavaFX Application Thread” java.lang.RuntimeException: java.lang.reflect.InvocationTargetException 线程“JavaFX 应用程序线程”中的异常 java.lang.RuntimeException: java.lang.reflect.InvocationTargetException Z47A34A9D6CE8F6ECB9778FXML888B01C260 - Exception in thread “JavaFX Application Thread” java.lang.RuntimeException: java.lang.reflect.InvocationTargetException JavaFX FXML
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM