O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. Let's first create a class with empty methods, which would represent the main application for launching the application as well as the JavaFX UI:
        public class BrowserDemo extends Application{
          public static void main(String[] args) {
            Application.launch(args);
          }
          @Override
          public void start(Stage stage) {
            //this will have all the JavaFX related code
          }
        }

In the subsequent steps, we will write all our code within the start(Stage stage) method.

  1. Let's create a javafx.scene.web.WebView component, which will render our web page. This has the required javafx.scene.web.WebEngine instance, which manages loading of the web page:
        WebView webView = new WebView();
  1. Get the instance of javafx.scene.web.WebEngine used by webView. We will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required