Presenting web content with WebView

Let's look at a simple WebView example:

// chapter9/web/WebViewDemo.javapublic void start(Stage primaryStage) {    WebView wv = new WebView();    wv.getEngine().load("https://stackoverflow.com/questions/tagged/javafx");    StackPane root = new StackPane(wv);    primaryStage.setTitle("JavaFX on SO");    primaryStage.setScene(new Scene(root, 400, 250));    primaryStage.show();}

This loads and shows a page from stackoverflow.com:

In the next section, let's look at useful properties of WebView: the context menu and accessibility features.

Get Mastering JavaFX 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.