/* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. */ import java.util.List; import javafx.application.Application; import javafx.application.Platform; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.control.Button; import javafx.scene.control.TextField; import javafx.scene.layout.*; import javafx.scene.web.*; import javafx.stage.Stage; public class WebLauncher extends Application { private static final String URL = "http://www.yahoo.com"; Scene createScene(String url) { final WebView webView = new WebView(); VBox.setVgrow(webView, Priority.ALWAYS); final WebEngine webEngine = webView.getEngine(); webEngine.load(url); final TextField urlBox = new TextField(); urlBox.setText(url); HBox.setHgrow(urlBox, Priority.ALWAYS); urlBox.setOnAction((ev) -> { webEngine.load(urlBox.getText()); }); Button goButton = new Button("Go"); goButton.setOnAction((ev) -> { webEngine.load(urlBox.getText()); }); HBox naviBar = new HBox(); naviBar.getChildren().addAll(urlBox, goButton); VBox root = new VBox(); root.getChildren().addAll(naviBar, webView); Scene scene = new Scene(root); scene.setFill(Color.GRAY); return scene; } @Override public void start(Stage stage) { List args = getParameters().getRaw(); String url = args.size() > 0 ? args.get(0) : URL; stage.setScene(createScene(url)); stage.setTitle("WebLauncher (JavaFX Sample)"); stage.sizeToScene(); stage.show(); // Exit after three seconds (which should be a good time to proke the bug) Thread t = new Thread(() -> { try { Thread.sleep(3000); } catch (InterruptedException ex) {} Platform.exit(); }); t.setDaemon(true); t.start(); } public static void main(String[] args) { launch(args); } }