6

I am looking for a way to display an html file in a different stage once the help button is clicked.

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 Answer 1

6

Your code is fine except that you forgot to add the webview to the scene, do

((Pane) helpScene.getRoot()).getChildren().add(browser);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.