Let's look at a simple WebView example:
// chapter9/web/WebViewDemo.java
public 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.