I am looking for a way to display an html file in a different stage once the help button is clicked.
我正在寻找一种在单击帮助按钮后在不同阶段显示html文件的方法。
public void handleButtonAction(ActionEvent event) throws IOException {
if (event.getSource() == help) {
stage = (Stage) help.getScene().getWindow();
root = FXMLLoader.load(getClass().getResource("help.fxml"));
WebView browser = new WebView();
Scene helpScene = new Scene(root);
Stage helpStage = new Stage();
helpStage.setTitle("Help Menu");
helpStage.setScene(helpScene);
URL url = getClass().getResource("readme.html");
browser.getEngine().load(url.toExternalForm());
helpStage.show();
}
}
1 个解决方案
#1
5
Your code is fine except that you forgot to add the webview to the scene, do
您的代码很好,除了您忘记将webview添加到场景中
((Pane) helpScene.getRoot()).getChildren().add(browser);
#1
5
Your code is fine except that you forgot to add the webview to the scene, do
您的代码很好,除了您忘记将webview添加到场景中
((Pane) helpScene.getRoot()).getChildren().add(browser);