How to pass data from JavaScript to JavaFX

后端 未结 1 913
耶瑟儿~
耶瑟儿~ 2021-01-25 23:21

In my JavaFX application, I have a WebView to load HTML contents. Is there a way to pass Javascript variables and manipulate it in JavaFX App. Let\'s say I have a variable

相关标签:
1条回答
  • 2021-01-25 23:39

    It is possible - assuming your webview is in a webView variable, and you want your FULLNAME variable loaded into fullNameField, try executing this on the Java side:

    String fullName = (String) webview1.getEngine().executeScript("FULLNAME;");
    fullNameField.setText(fullName);
    
    0 讨论(0)
提交回复
热议问题