java - How to load a local HTML file using WebView in JavaFX -


i looking way display html file in different stage once button 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();        } } 

your code fine except forgot add webview scene, do

((pane) helpscene.getroot()).getchildren().add(browser); 

Comments