@Override public void start(Stage stage) throws Exception { if (headless) { System.setProperty("headless.geometry", width + "x" + height); NativePlatform platform = NativePlatformFactory.getNativePlatform(); Field field = NativePlatform.class.getDeclaredField("screen"); field.setAccessible(true); field.set(platform, null); Screen.notifySettingsChanged(); } if (stage == null) { stage = new Stage(); } Platform.setImplicitExit(false); WebView view = new WebView(); view.setCache(false); StackPane root = new StackPane(); root.setCache(false); if (headless) { stage.initStyle(StageStyle.UNDECORATED); } WebEngine engine = view.getEngine(); engine.getHistory().setMaxSize(HISTORY_SIZE); engine.setUserAgent(Long.toString(settingsId)); Accessor.getPageFor(engine).setDeveloperExtrasEnabled(false); Accessor.getPageFor(engine).setUsePageCache(false); root.getChildren().add(view); stage.setScene(new Scene(root, width, height)); stage.sizeToScene(); engine.titleProperty().addListener(new TitleListener(stage)); stage.show(); synchronized (lock) { myStage = stage; myView = view; lock.notifyAll(); } }