javafx.concurrent.Worker.State Java Examples
The following examples show how to use
javafx.concurrent.Worker.State.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RFXWebView.java From marathonv5 with Apache License 2.0 | 7 votes |
private void init(Node source) { WebView webview = (WebView) source; if (webview.getProperties().get("marathon_listener_installed") == null) { webview.getProperties().put("marathon_listener_installed", Boolean.TRUE); WebEngine webEngine = webview.getEngine(); if (webEngine.getLoadWorker().stateProperty().get() == State.SUCCEEDED) { loadScript(webview); } webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() { @Override public void changed(ObservableValue<? extends State> ov, State oldState, State newState) { if (newState == State.SUCCEEDED) { loadScript(webview); } } }); } JavaFXWebViewElement.init(source); }
Example #2
Source File: BrowserPanel.java From zap-extensions with Apache License 2.0 | 6 votes |
private void listenToStateChangesForAdjustingPanelHeightToWebsite() { engine.getLoadWorker() .stateProperty() .addListener( new ChangeListener<Object>() { @Override public void changed( ObservableValue<?> observable, Object oldValue, Object newValue) { if (State.SUCCEEDED == newValue && resizeOnLoad) { resizeOnLoad = false; final int height = getWebsiteHeight(); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { setWebsiteHeight(height); } }); } } }); }
Example #3
Source File: WebViewPreview.java From markdown-writer-fx with BSD 2-Clause "Simplified" License | 6 votes |
private void createNodes() { webView = new WebView(); webView.setFocusTraversable(false); // disable WebView default drag and drop handler to allow dropping markdown files webView.setOnDragEntered(null); webView.setOnDragExited(null); webView.setOnDragOver(null); webView.setOnDragDropped(null); webView.setOnDragDetected(null); webView.setOnDragDone(null); webView.getEngine().getLoadWorker().stateProperty().addListener((ob,o,n) -> { if (n == State.SUCCEEDED && !runWhenLoadedList.isEmpty()) { ArrayList<Runnable> runnables = new ArrayList<>(runWhenLoadedList); runWhenLoadedList.clear(); for (Runnable runnable : runnables) runnable.run(); } }); }
Example #4
Source File: HTMLPanel.java From Hook-Manager with Mozilla Public License 2.0 | 6 votes |
public void doWhenFinished(Runnable task) { Platform.runLater(new Runnable() { @Override public void run() { engine.getLoadWorker().stateProperty() .addListener(new ChangeListener<State>() { @Override public void changed(ObservableValue ov, State oldState, State newState) { if(newState == State.SUCCEEDED) { task.run(); engine.getLoadWorker().stateProperty() .removeListener(this); } } }); } }); }
Example #5
Source File: Browser.java From mars-sim with GNU General Public License v3.0 | 6 votes |
public void loadPage(TextField textField, //ProgressBar progressBar, WebEngine webEngine, WebView webView) { String route = textField.getText(); if (route !=null) if (!route.substring(0, 7).equals("http://")) { route = "http://" + route; textField.setText(route); } System.out.println("Loading route: " + route); //progressBar.progressProperty().bind(webEngine.getLoadWorker().progressProperty()); webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() { @Override public void changed(ObservableValue<? extends State> value, State oldState, State newState) { if(newState == State.SUCCEEDED){ System.out.println("Location loaded + " + webEngine.getLocation()); } } }); webEngine.load(route); }
Example #6
Source File: JavaFXWebViewElement.java From marathonv5 with Apache License 2.0 | 6 votes |
public static void init(Node source) { WebView webview = (WebView) source; if (webview.getProperties().get("marathon_player_installed") == null) { webview.getProperties().put("marathon_player_installed", Boolean.TRUE); WebEngine webEngine = webview.getEngine(); if (webEngine.getLoadWorker().stateProperty().get() == State.SUCCEEDED) { loadScript(webview, webEngine); } webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() { @Override public void changed(ObservableValue<? extends State> ov, State oldState, State newState) { if (newState == State.SUCCEEDED) { loadScript(webview, webEngine); } } }); } }
Example #7
Source File: ChatWritePane.java From oim-fx with MIT License | 6 votes |
private void iniEvent() { webView.setOnInputMethodTextChanged(new EventHandler<InputMethodEvent>() { @Override public void handle(InputMethodEvent e) { processInputMethodEvent(e); } }); webView.setOnDragDropped(a -> { }); webEngine.getLoadWorker().stateProperty().addListener((ObservableValue<? extends State> ov, State oldState, State newState) -> { if (newState == State.SUCCEEDED) { initWeb(webEngine); } }); webView.addEventHandler(KeyEvent.ANY, event -> { }); }
Example #8
Source File: WritePanel.java From oim-fx with MIT License | 6 votes |
private void initComponent() { this.getChildren().add(webView); webEngine = webView.getEngine(); webPage = Accessor.getPageFor(webEngine); webPage.setEditable(true); webView.setFocusTraversable(true); // webView.getEngine().setUserStyleSheetLocation(getClass().getResource("/resources/common/css/webview.css").toExternalForm()); // webPage.setBackgroundColor(255); webView.setPrefWidth(300); // webView.setOpacity(0.92); // webView.setBlendMode(BlendMode.DARKEN); // .setBackground(Background.EMPTY); webView.setOnDragDropped(a -> { }); webEngine.getLoadWorker().stateProperty().addListener((ObservableValue<? extends State> ov, State oldState, State newState) -> { if (newState == State.SUCCEEDED) { initWeb(webEngine); } }); initializeHtml(); }
Example #9
Source File: HyperlinkRedirectListener.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) { if (State.SUCCEEDED.equals(newValue)) { Document document = webView.getEngine().getDocument(); NodeList anchors = document.getElementsByTagName(ANCHOR_TAG); for (int i = 0; i < anchors.getLength(); i++) { Node node = anchors.item(i); EventTarget eventTarget = (EventTarget) node; eventTarget.addEventListener(CLICK_EVENT, this, false); } } }
Example #10
Source File: ChatShowPane.java From oim-fx with MIT License | 5 votes |
private void iniEvent() { webEngine.getLoadWorker().stateProperty().addListener((ObservableValue<? extends State> ov, State oldState, State newState) -> { if (newState == State.SUCCEEDED) { isLoad = true; initWeb(webEngine); if (!jsList.isEmpty()) { int size = jsList.size(); for (int i = 0; i < size; i++) { String js = jsList.get(i); webEngine.executeScript(js); } jsList.clear(); } } }); webView.setOnMouseClicked(m -> { m.consume(); }); webView.setOnDragDropped(a -> { }); WebViews.addHyperlinkListener(webView, new WebViewHyperlinkListener() { @Override public boolean hyperlinkUpdate(HyperlinkEvent event) { System.out.println(event.getURL()); return true; } }, javax.swing.event.HyperlinkEvent.EventType.ACTIVATED); }
Example #11
Source File: AuditLogTaskRecord.java From old-mzmine3 with GNU General Public License v2.0 | 5 votes |
public AuditLogTaskRecord(@Nonnull Task<?> task) { this.taskMessage = task.getMessage(); this.taskTitle = task.getTitle(); task.stateProperty().addListener(new ChangeListener<State>() { public void changed(ObservableValue<? extends State> ov, State oldState, State newState) { taskStatus = newState; } }); }
Example #12
Source File: WebViewStyleTest.java From oim-fx with MIT License | 5 votes |
@Override public void start(final Stage primaryStage) { primaryStage.setTitle("What World"); WebView webView = new WebView(); WebPage webPage = null; WebEngine webEngine = webView.getEngine(); webEngine.getLoadWorker().stateProperty().addListener((ObservableValue<? extends State> ov, State oldState, State newState) -> { System.out.println("loadWorker"); if (newState == State.SUCCEEDED) { JSObject window = (JSObject) webEngine.executeScript("window"); window.setMember("app", app); System.out.println("app"); } }); webPage = Accessor.getPageFor(webEngine); webPage.setJavaScriptEnabled(true); webPage.setEditable(false); webPage.setContextMenuEnabled(false); webView.setFocusTraversable(true); webView.getEngine().load(WebViewStyleTest.class.getResource("WebViewStyleTest.html").toExternalForm()); BorderPane bp=new BorderPane(); Scene scene = new Scene(bp); scene.getStylesheets().add(this.getClass().getResource("WebView.css").toString()); bp.setCenter(webView); primaryStage.setScene(scene); primaryStage.show(); }
Example #13
Source File: Browser.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public Stage startWebTool() { Stage webStage = new Stage(); webStage.setTitle("Mars Simulation Project - Online Tool"); webStage.initModality(Modality.APPLICATION_MODAL); final WebView webView = new WebView(); final WebEngine webEngine = webView.getEngine(); ScrollPane scrollPane = new ScrollPane(); scrollPane.setFitToWidth(true); scrollPane.setContent(webView); webEngine.getLoadWorker().stateProperty() .addListener(new ChangeListener<State>() { //@Override public void changed(@SuppressWarnings("rawtypes") ObservableValue ov, State oldState, State newState) { if (newState == Worker.State.SUCCEEDED) { webStage.setTitle(webEngine.getLocation()); } } }); webEngine.load("http://mars-sim.sourceforge.net/#development"); //webEngine.load("http://jquerymy.com/"); Scene webScene = new Scene(scrollPane); webStage.setScene(webScene); return webStage; }
Example #14
Source File: HyperlinkRedirectListener.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
@Override public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) { if(State.SUCCEEDED.equals(newValue)) { Document document = webView.getEngine().getDocument(); NodeList anchors = document.getElementsByTagName(ANCHOR_TAG); for(int i = 0; i < anchors.getLength(); i++) { Node node = anchors.item(i); EventTarget eventTarget = (EventTarget) node; eventTarget.addEventListener(CLICK_EVENT, this, false); } } }
Example #15
Source File: DemoBrowser.java From FxDock with Apache License 2.0 | 5 votes |
public DemoBrowser() { super(DemoGenerator.BROWSER); setTitle("Browser / " + CSystem.getJavaVersion()); addressField = new TextField(); addressField.addEventHandler(KeyEvent.KEY_PRESSED, (ev) -> handleKeyTyped(ev)); LocalSettings.get(this).add("URL", addressField); view = new WebView(); view.getEngine().setOnError((ev) -> handleError(ev)); view.getEngine().setOnStatusChanged((ev) -> handleStatusChange(ev)); Worker<Void> w = view.getEngine().getLoadWorker(); w.stateProperty().addListener(new ChangeListener<Worker.State>() { public void changed(ObservableValue v, Worker.State old, Worker.State cur) { log.debug(cur); if(w.getException() != null && cur == State.FAILED) { log.error(w.getException()); } } }); statusField = new Label(); CPane p = new CPane(); p.setGaps(10, 5); p.setCenter(view); p.setBottom(statusField); setContent(p); FX.later(() -> reload()); }
Example #16
Source File: DesktopSearchController.java From FXDesktopSearch with Apache License 2.0 | 5 votes |
public void configure(final DesktopSearchMain aApplication, final Backend aBackend, final String aSearchURL, final Window aWindow) { gateway = new DesktopGateway(aApplication, DesktopSearchController.this); window = aWindow; application = aApplication; backend = aBackend; backend.setProgressListener(new FXProgressListener()); watcherThread = new ProgressWatcherThread(); webView.getEngine().setJavaScriptEnabled(true); webView.getEngine().getLoadWorker().stateProperty().addListener((ov, t, t1) -> { if (t1 == State.SUCCEEDED) { final var windowGlobalJSNamespace = (JSObject) webView.getEngine().executeScript("window"); windowGlobalJSNamespace.setMember("desktop", gateway); } }); webView.setContextMenuEnabled(false); webView.getEngine().load(aSearchURL); webView.getEngine().setJavaScriptEnabled(true); if (aApplication.getConfigurationManager().getConfiguration().isCrawlOnStartup()) { // Scedule a crawl run 5 seconds after startup... final var theTimer = new Timer(); theTimer.schedule(new TimerTask() { @Override public void run() { Platform.runLater(() -> recrawl()); } }, 5000); } }
Example #17
Source File: GoogleLoginDialog.java From zest-writer with GNU General Public License v3.0 | 5 votes |
public GoogleLoginDialog(LoginDialog parent) { super(); this.setTitle(Configuration.getBundle().getString("ui.dialog.auth.google.title")); final WebView browser = new WebView(); final WebEngine webEngine = browser.getEngine(); ScrollPane scrollPane = new ScrollPane(); scrollPane.setContent(browser); CookieManager manager = new CookieManager(); CookieHandler.setDefault(manager); webEngine.setJavaScriptEnabled(false); this.getDialogPane().setContent(scrollPane); this.getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL); webEngine.getLoadWorker().stateProperty().addListener((ov, oldState, newState) -> { if(newState == State.RUNNING) { if(webEngine.getLocation().contains("accounts.google.com/ServiceLoginAuth")) { scrollPane.setVisible(false); } } if(newState == State.SUCCEEDED) { if("https://zestedesavoir.com/".equals(webEngine.getLocation())) { Element elementary = webEngine.getDocument().getDocumentElement(); Element logbox = getLogBox(elementary); String pseudo = getPseudo(logbox); String id = getId(logbox); MainApp.getZdsutils().authToGoogle(manager.getCookieStore().getCookies(), pseudo, id); getThis().close(); parent.close(); } else { if(webEngine.getLocation().contains("accounts.google.com/ServiceLoginAuth")) { scrollPane.setVisible(true); } } } }); webEngine.load("https://zestedesavoir.com/login/google-oauth2/"); }
Example #18
Source File: WebViewJavaScriptToJavaDemo.java From oim-fx with MIT License | 5 votes |
@Override public void start(final Stage primaryStage) { primaryStage.setTitle("What World"); WebView webView = new WebView(); WebPage webPage = null; WebEngine webEngine = webView.getEngine(); webEngine.getLoadWorker().stateProperty().addListener((ObservableValue<? extends State> ov, State oldState, State newState) -> { System.out.println("loadWorker"); if (newState == State.SUCCEEDED) { JSObject window = (JSObject) webEngine.executeScript("window"); window.setMember("app", app); System.out.println("app"); } }); webPage = Accessor.getPageFor(webEngine); webPage.setJavaScriptEnabled(true); webPage.setEditable(false); webPage.setContextMenuEnabled(false); webView.setFocusTraversable(true); webView.getEngine().load(WebViewJavaScriptToJavaDemo.class.getResource("ScriptToJava.html").toExternalForm()); Group root = new Group(); Scene scene = new Scene(root, 1000, 550, Color.LIGHTBLUE); root.getChildren().add(webView); primaryStage.setScene(scene); primaryStage.show(); }
Example #19
Source File: JavaFXWebViewElement.java From marathonv5 with Apache License 2.0 | 5 votes |
private boolean documentHasSelector(String selector) { return EventQueueWait.exec(new Callable<Boolean>() { @Override public Boolean call() throws Exception { return ((WebView) getComponent()).getEngine().getLoadWorker().stateProperty().get() == State.SUCCEEDED && getComponent().getProperties().containsKey("player") && ((JSObject) getComponent().getProperties().get("document")).call("querySelector", selector) != null; } }); }
Example #20
Source File: ACEEditor.java From marathonv5 with Apache License 2.0 | 5 votes |
private void initComponent() { webView = new WebView(); String externalForm = ACEEditor.class.getResource("/Ace.html").toExternalForm(); WebEngine engine = webView.getEngine(); engine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() { @Override public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) { if (newValue != State.SUCCEEDED) { return; } JSObject window = (JSObject) engine.executeScript("window"); window.setMember("java", ACEEditor.this); engine.executeScript("console.log = function(message)\n" + "{\n" + " java.log(message);\n" + "};"); ACEEditor.this.engine = engine; setOptions(new JSONObject().put("showLineNumbers", showLinenumbers).put("firstLineNumber", startLineNumber) .put("overwrite", false)); loadPreferences(); hookKeyBindings(); } }); engine.load(externalForm); ToolBarContainer container = ToolBarContainer.createDefaultContainer(Orientation.RIGHT); if (withToolbar) { ToolBarPanel toolBarPanel = container.getToolBarPanel(); createToolBars(toolBarPanel); } container.setContent(webView); this.node = container; }
Example #21
Source File: HttpDownApplication.java From proxyee-down with Apache License 2.0 | 5 votes |
public Browser() { getChildren().add(browser); webEngine.getLoadWorker().stateProperty().addListener( (ObservableValue<? extends State> ov, State oldState, State newState) -> { if (newState == State.SUCCEEDED) { JSObject win = (JSObject) webEngine.executeScript("window"); win.setMember("jNative", new JNative()); } }); }
Example #22
Source File: Minimal.java From JavaFX with MIT License | 4 votes |
@Override public void start(Stage primaryStage) throws Exception { // creating Layout final Group root = new Group(); Scene scene = new Scene(root, 400, 400); primaryStage.setScene(scene); primaryStage.setResizable(false); StackPane waitingPane = new StackPane(); final ProgressBar progress = new ProgressBar(); Label load = new Label("loading things..."); progress.setTranslateY(-25); load.setTranslateY(25); waitingPane.getChildren().addAll(new Rectangle(400, 400, Color.WHITE), load, progress); root.getChildren().add(waitingPane); // Task for computing the Panels: Task<Void> task = new Task<Void>() { @Override protected Void call() throws Exception { for (int i = 0; i < 20; i++) { try { Thread.sleep(new Random().nextInt(1000)); } catch (InterruptedException ex) { ex.printStackTrace(); } final double prog = i * 0.05; Platform.runLater(new Runnable() { public void run() { progress.setProgress(prog); } }); } return null; } }; // stateProperty for Task: task.stateProperty().addListener(new ChangeListener<Worker.State>() { @Override public void changed(ObservableValue<? extends State> observable, State oldValue, Worker.State newState) { if (newState == Worker.State.SUCCEEDED) { loadPanels(root); } } }); // start Task new Thread(task).start(); primaryStage.show(); }
Example #23
Source File: Minimal.java From JavaFX with MIT License | 4 votes |
private void loadPanels(Group root) { // change to loadPanel: root.getChildren().set(0, createLoadPane()); // Service: final Service<Rectangle> RecBuilder = new Service<Rectangle>() { @Override protected Task<Rectangle> createTask() { return new Task<Rectangle>() { @Override protected Rectangle call() throws InterruptedException { updateMessage("loading rectangle . . ."); updateProgress(0, 10); for (int i = 0; i < 10; i++) { Thread.sleep(100); } updateMessage("Finish!"); return new Rectangle((380) / 3, (380) / 3, colors[counter]); } }; } }; // StateListener RecBuilder.stateProperty().addListener( new ChangeListener<Worker.State>() { @Override public void changed( ObservableValue<? extends Worker.State> observableValue, Worker.State oldState, Worker.State newState) { switch (newState) { case SCHEDULED: break; case READY: case RUNNING: break; case SUCCEEDED: Rectangle rec = RecBuilder.valueProperty() .getValue(); indicators[counter].progressProperty().unbind(); loading[counter].textProperty().unbind(); loadPane.getChildren().set(counter, rec); if (counter < 8) { counter++; nextPane(RecBuilder); } break; case CANCELLED: case FAILED: loading[counter].textProperty().unbind(); loading[counter].setText("Failed!"); if (counter < 8) { counter++; nextPane(RecBuilder); } break; } } }); // begin PanelBuilding: nextPane(RecBuilder); }
Example #24
Source File: HelpController.java From CPUSim with GNU General Public License v3.0 | 4 votes |
/** * Initializes the WebView pane, where * the help HTML pages are rendered. */ public void initializeWebView() { WebEngine webEngine = webView.getEngine(); //webView.setZoom(javafx.stage.Screen.getPrimary().getDpi() / 96); webEngine.getLoadWorker().stateProperty().addListener( (arg0, oldState, newState) -> { if (newState == State.SUCCEEDED) { WebEngine webEngine1 = webView.getEngine(); //This next two lines are a work around //Due to webEngine.load() problems. searchController.setDocumentCopy(webEngine1.getDocument()); //loads tags on change. Somewhat of a hack for handling switching //between files when searching is active. Highlights words //immediately when displaying a new file in the web view searchController.addHighlightTagsToBody(webEngine1 .getDocument()); String s = webEngine1.getLocation(); int i = webEngine1.getLocation().indexOf(pref); String afterPref = s.substring(i); if (afterPref.contains("#")) { afterPref = afterPref.substring(0, afterPref.indexOf ("#")); } String newItemsName = urls.get(afterPref); TreeItem<String> ti = getItemFromString(newItemsName, treeView.getRoot()); if (!previousItem.getValue().equals(ti.getValue())) { msm.select(ti); } previousItem = ti; } }); URL url = getClass().getResource("/html/help/generalHelp/introduction.html"); if (startingPage != null) { url = getClass().getResource(urls.get(startingPage)); } webEngine.load(url.toExternalForm() + appendString); }
Example #25
Source File: AuditLogTaskRecord.java From old-mzmine3 with GNU General Public License v2.0 | 4 votes |
@Nonnull public State getTaskStatus() { return taskStatus; }
Example #26
Source File: MdConvertController.java From zest-writer with GNU General Public License v3.0 | 4 votes |
private void initRenderTask() { renderTask = new Service<String>() { @Override protected Task<String> createTask() { return new Task<String>() { @Override protected String call() throws Exception { String html = getMdBox().markdownToHtml(sourceText.getText()); if (html != null) { return MainApp.getMdUtils().addHeaderAndFooter(html); } else { throw new IOException(); } } }; } }; renderTask.setOnFailed(t -> { renderTask.restart(); }); renderTask.setOnSucceeded(t -> { Platform.runLater(() -> { yRenderPosition = getVScrollValue(renderView); xRenderPosition = getHScrollValue(renderView); renderView.getEngine().loadContent(renderTask.getValue()); performStats(); renderTask.reset(); if(needRefresh.getValue()) { needRefresh.set(false); renderTask.start(); } }); }); renderView.getEngine().getLoadWorker().stateProperty() .addListener((ObservableValue<? extends State> ov, State oldState, State newState) -> { if (newState == State.SUCCEEDED) { Platform.runLater(() -> scrollTo(renderView, xRenderPosition, yRenderPosition)); } }); }
Example #27
Source File: MdConvertController.java From zest-writer with GNU General Public License v3.0 | 4 votes |
public void setMdBox(MdTextController mdBox, Textual extract) { this.mdBox = mdBox; initCurrentComponents(extract); tab.setText(extract.getTitle()); Platform.runLater(() -> { saved.addListener((observableValue, s, s2) -> { if(s2) { tab.setText(extract.getTitle()); } else { tab.setText("! " + extract.getTitle()); } }); sourceText.replaceText(extract.getMarkdown()); initStats(); sourceText.getUndoManager().forgetHistory(); sourceText.richChanges() .filter(ch -> !ch.getInserted().equals(ch.getRemoved())) .subscribe(change -> { sourceText.getUndoManager().mark(); getMdBox().setCurrentSaved(false); if(renderTask.getState().equals(State.READY)) { renderTask.start(); needRefresh.set(false); } else { needRefresh.set(true); } }); if(renderTask.getState().equals(State.READY)) { renderTask.start(); } }); tab.setOnSelectionChanged(t -> { initCurrentComponents(extract); TreeItem<ContentNode> selected = mdBox.selectItemOnTree(mdBox.getSummary().getRoot(), extract); Platform.runLater(() -> { if(selected != null) { mdBox.getSummary().getSelectionModel().select(selected); } sourceText.requestFocus(); initStats(); }); }); }
Example #28
Source File: WebViewJavaScriptDemo.java From oim-fx with MIT License | 4 votes |
@Override public void start(final Stage primaryStage) { primaryStage.setTitle("Hello World"); WebView webView = new WebView(); // WebPage webPage = null; WebEngine webEngine = webView.getEngine(); // JSObject window = (JSObject) webEngine.executeScript("window"); // window.setMember("app", new JavaApplication()); // webPage = Accessor.getPageFor(webEngine); // webPage.setJavaScriptEnabled(true); // webPage.setEditable(false); // webPage.setContextMenuEnabled(false); // webView.setFocusTraversable(true); StringBuilder html = new StringBuilder(); html.append("<html>"); html.append(" <head>"); html.append(" <title></title>"); html.append(" <meta charset=\"UTF-8\">"); html.append(" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"); html.append(" <script type=\"text/javascript\">"); html.append(createLastJavaScript()); html.append(createCheckElementJavaScript()); html.append(createBodyJavaScript()); html.append(" </script>"); html.append(" </head>"); html.append(" <body style=\"word-wrap:break-word;\" >"); html.append(" <a href=\"app.exit();\" onclick=\"app.exit()\">Click here to exit application</a>"); html.append(" <a href=\"javascript:void()\" onclick=\"app.show('hhh')\">hhh</a>"); html.append(" </body>"); html.append("</html>"); webEngine.getLoadWorker().stateProperty().addListener((ObservableValue<? extends State> ov, State oldState, State newState) -> { System.out.println("loadWorker"); if (newState == State.SUCCEEDED) { System.out.println("SUCCEEDED"); } }); webEngine.loadContent(html.toString(), "text/html"); Group root = new Group(); Scene scene = new Scene(root, 1000, 550, Color.LIGHTBLUE); root.getChildren().add(webView); primaryStage.setScene(scene); primaryStage.show(); }