import javafx.application.Application; import javafx.application.Platform; import javafx.scene.Scene; import javafx.scene.web.WebEngine; import javafx.scene.web.WebView; import javafx.stage.Stage; import java.util.Timer; import java.util.TimerTask; public class FXTest extends Application { private static final String URL = "http://www.netbeans.org"; private static final double MIN_ZOOM = .1; // 1.0 means 100% private static final double MAX_ZOOM = 2; private static final long DELAY = 1000; // ms int n = 0; Scene createScene(String url) { final WebView webView = new WebView(); final WebEngine webEngine = webView.getEngine(); webEngine.load(url); Scene scene = new Scene(webView); TimerTask task = new TimerTask() { @Override public void run() { Platform.runLater(new Runnable() { public void run() { webView.setZoom(MIN_ZOOM + Math.random() * (MAX_ZOOM - MIN_ZOOM)); System.out.println(++n + " webView.getZoom() = " + webView.getZoom()); } }); } }; new Timer(true).schedule(task, 5000, DELAY); return scene; } @Override public void start(Stage stage) { stage.setTitle("WebLauncher (JavaFX Sample)"); stage.setScene(createScene(URL)); stage.sizeToScene(); stage.show(); } public static void main(String[] args) { Application.launch(args); } }