javafx.scene.web.WebEngine Java Examples
The following examples show how to use
javafx.scene.web.WebEngine.
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: OrsonChartsFXDemo.java From jfree-fxdemos with BSD 3-Clause "New" or "Revised" License | 6 votes |
private SplitPane createChartPane() { CategoryDataset3D dataset = SampleData.createCompanyRevenueDataset(); Chart3D chart = AreaChart3DFXDemo1.createChart(dataset); Chart3DViewer viewer = new Chart3DViewer(chart); this.splitter = new SplitPane(); splitter.setOrientation(Orientation.VERTICAL); final BorderPane borderPane = new BorderPane(); borderPane.setCenter(viewer); // Bind canvas size to stack pane size. viewer.prefWidthProperty().bind(borderPane.widthProperty()); viewer.prefHeightProperty().bind(borderPane.heightProperty()); final StackPane sp2 = new StackPane(); this.chartDescription = new WebView(); WebEngine webEngine = chartDescription.getEngine(); webEngine.load(AreaChart3DFXDemo1.class.getResource("AreaChart3DFXDemo1.html").toString()); sp2.getChildren().add(chartDescription); splitter.getItems().addAll(borderPane, sp2); splitter.setDividerPositions(0.70f, 0.30f); return splitter; }
Example #3
Source File: NetworkTools.java From MyBox with Apache License 2.0 | 6 votes |
public static Map<String, String> readCookie(WebEngine webEngine) { try { String s = (String) webEngine.executeScript("document.cookie;"); String[] vs = s.split(";"); Map<String, String> m = new HashMap<>(); for (String v : vs) { String[] vv = v.split("="); if (vv.length < 2) { continue; } m.put(vv[0].trim(), vv[1].trim()); } return m; } catch (Exception e) { logger.debug(e.toString()); return null; } }
Example #4
Source File: HtmlWebView.java From Learn-Java-12-Programming with MIT License | 6 votes |
public void start(Stage primaryStage) { try { WebView wv = new WebView(); WebEngine we = wv.getEngine(); String html = "<html><center><h2>Hello, world!</h2></center></html>"; we.loadContent(html, "text/html"); Scene scene = new Scene(wv, 200, 60); primaryStage.setTitle("My HTML page"); primaryStage.setScene(scene); primaryStage.onCloseRequestProperty() .setValue(e -> System.out.println("Bye! See you later!")); primaryStage.show(); } catch (Exception ex){ ex.printStackTrace(); } }
Example #5
Source File: HtmlWebView.java From Learn-Java-12-Programming with MIT License | 6 votes |
public void start9(Stage primaryStage) { try { Text txt = new Text("Fill the form and click Submit"); WebView wv = new WebView(); WebEngine we = wv.getEngine(); File f = new File("src/main/resources/form.html"); we.load(f.toURI().toString()); VBox vb = new VBox(txt, wv); vb.setSpacing(10); vb.setAlignment(Pos.CENTER); vb.setPadding(new Insets(10, 10, 10, 10)); Scene scene = new Scene(vb, 300, 200); primaryStage.setScene(scene); primaryStage.setTitle("JavaFX with embedded HTML"); primaryStage.onCloseRequestProperty() .setValue(e -> System.out.println("Bye! See you later!")); primaryStage.show(); } catch (Exception ex){ ex.printStackTrace(); } }
Example #6
Source File: Blurb.java From marathonv5 with Apache License 2.0 | 6 votes |
private void initComponents() { webView.setId("webView"); webView.getEngine().getLoadWorker().stateProperty().addListener(new HyperlinkRedirectListener(webView)); VBox.setVgrow(webView, Priority.ALWAYS); WebEngine engine = webView.getEngine(); if (blurbInfo.getURL() != null) engine.load(blurbInfo.getURL().toExternalForm()); else engine.loadContent(blurbInfo.getHtml()); buttonBar.setId("buttonBar"); buttonBar.setButtonMinWidth(Region.USE_PREF_SIZE); buttonBar.getButtons().add(okButton); if (blurbInfo.isCancelNeeded()) { buttonBar.getButtons().add(cancelButton); } okButton.setOnAction((e) -> onOk()); cancelButton.setOnAction((e) -> onCancel()); }
Example #7
Source File: DeferredHtmlRendering.java From ReactFX with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void start(Stage primaryStage) { TextArea textArea = new TextArea(); WebView webView = new WebView(); WebEngine engine = webView.getEngine(); EventStreams.valuesOf(textArea.textProperty()) .successionEnds(Duration.ofMillis(500)) .subscribe(html -> engine.loadContent(html)); SplitPane root = new SplitPane(); root.getItems().addAll(textArea, webView); Scene scene = new Scene(root); primaryStage.setScene(scene); primaryStage.show(); }
Example #8
Source File: UpdateDialogController.java From updatefx with MIT License | 6 votes |
private void initialize() { URL changelog = release.getApplication().getChangelog(); if (changelog != null) { WebEngine engine = changeView.getEngine(); String finalURL = String.format("%s?from=%d&to=%d", changelog, currentReleaseID, release.getId()); engine.load(finalURL); } else { changeView.setVisible(false); changeView.setManaged(false); } Object[] messageArguments = { release.getApplication().getName(), currentVersion, release.getVersion() }; MessageFormat formatter = new MessageFormat(""); formatter.setLocale(resources.getLocale()); if (release.getLicenseVersion() != currentLicenseVersion) { formatter.applyPattern(resources.getString("infotext.paidupgrade")); } else { formatter.applyPattern(resources.getString("infotext.freeupgrade")); } infoLabel.setText(formatter.format(messageArguments)); infoLabel.autosize(); }
Example #9
Source File: MdTextController.java From zest-writer with GNU General Public License v3.0 | 6 votes |
@FXML private void handleValidateButtonAction(ActionEvent event) { String s = StringEscapeUtils.unescapeHtml4(markdownToHtml(currentSourceText.getText())); if (MdConvertController.corrector == null) { MdConvertController.corrector = new Corrector(); } try { String result = MdConvertController.corrector.checkHtmlContent(s); WebEngine webEngine = currentRenderView.getEngine(); webEngine.loadContent("<!doctype html><html lang='fr'><head><meta charset='utf-8'><base href='" + MainApp.class.getResource("assets").toExternalForm() + "' /></head><body>" + result + "</body></html>"); webEngine.setUserStyleSheetLocation(MainApp.class.getResource("assets/static/css/content.css").toExternalForm()); } catch (DOMException e) { log.error(e.getMessage(), e); } }
Example #10
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 #11
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 #12
Source File: JavaFXBrowserWithHistory.java From mars-sim with GNU General Public License v3.0 | 6 votes |
private static Object executejQuery(final WebEngine engine, String minVersion, String jQueryLocation, String script) { return engine.executeScript( "(function(window, document, version, callback) { " + "var j, d;" + "var loaded = false;" + "if (!(j = window.jQuery) || version > j.fn.jquery || callback(j, loaded)) {" + " var script = document.createElement(\"script\");" + " script.type = \"text/javascript\";" + " script.src = \"" + jQueryLocation + "\";" + " script.onload = script.onreadystatechange = function() {" + " if (!loaded && (!(d = this.readyState) || d == \"loaded\" || d == \"complete\")) {" + " callback((j = window.jQuery).noConflict(1), loaded = true);" + " j(script).remove();" + " }" + " };" + " document.documentElement.childNodes[0].appendChild(script) " + "} " + "})(window, document, \"" + minVersion + "\", function($, jquery_loaded) {" + script + "});"); }
Example #13
Source File: TextEditorPane.java From logbook-kai with MIT License | 6 votes |
private void setting() { WebEngine engine = this.webview.getEngine(); JSObject window = (JSObject) engine.executeScript("window"); Object ace = null; try { ace = engine.executeScript("ace"); } catch (Exception e) { } if (ace != null && ace != engine.executeScript("undefined")) { if (this.lang != null) { window.call("start", this.lang); this.lang = null; } if (this.source != null) { window.call("set", this.source); this.source = null; } if (this.readOnly != null) { window.call("setReadOnly", this.readOnly); this.readOnly = null; } } }
Example #14
Source File: TextEditorPane.java From logbook-kai with MIT License | 6 votes |
@FXML void initialize() { WebEngine engine = this.webview.getEngine(); engine.load(PluginServices.getResource("logbook/gui/text_editor_pane.html").toString()); engine.getLoadWorker().stateProperty().addListener( (ob, o, n) -> { if (n == Worker.State.SUCCEEDED) { this.setting(); } }); KeyCombination copy = new KeyCodeCombination(KeyCode.C, KeyCombination.CONTROL_DOWN); KeyCombination cut = new KeyCodeCombination(KeyCode.X, KeyCombination.CONTROL_DOWN); this.webview.addEventHandler(KeyEvent.KEY_PRESSED, event -> { if (copy.match(event) || cut.match(event)) { String text = String.valueOf(engine.executeScript("getCopyText()")); Platform.runLater(() -> { ClipboardContent content = new ClipboardContent(); content.putString(text); Clipboard.getSystemClipboard().setContent(content); }); } }); }
Example #15
Source File: IndexService.java From xJavaFxTool-spring with Apache License 2.0 | 6 votes |
/** * @Title: addWebView * @Description: 添加WebView视图 */ public void addWebView(String title, String url, String iconPath) { WebView browser = new WebView(); WebEngine webEngine = browser.getEngine(); if (url.startsWith("http")) { webEngine.load(url); } else { webEngine.load(IndexController.class.getResource(url).toExternalForm()); } if (indexController.getSingleWindowBootCheckBox().isSelected()) { JavaFxViewUtil.getNewStage(title, iconPath, new BorderPane(browser)); return; } Tab tab = new Tab(title); if (StringUtils.isNotEmpty(iconPath)) { ImageView imageView = new ImageView(new Image(iconPath)); imageView.setFitHeight(18); imageView.setFitWidth(18); tab.setGraphic(imageView); } tab.setContent(browser); indexController.getTabPaneMain().getTabs().add(tab); indexController.getTabPaneMain().getSelectionModel().select(tab); }
Example #16
Source File: CreditsStage.java From marathonv5 with Apache License 2.0 | 5 votes |
private void initComponents() { webView.setId("webView"); WebEngine engine = webView.getEngine(); engine.loadContent(getWebViewContent(), "text/html"); VBox.setVgrow(webView, Priority.ALWAYS); okButton.setOnAction((e) -> onOK()); buttonBar.setId("buttonBar"); buttonBar.getButtons().add(okButton); }
Example #17
Source File: MapSelectionTest.java From triplea with GNU General Public License v3.0 | 5 votes |
/** * {@link WebEngine} has a static initializer that expects a running JavaFX environment. To avoid * exceptions we manually set a private field to skip validation when mocking. */ private WebEngine mockWebEngine() throws Exception { final Class<?> clazz = Class.forName("com.sun.glass.ui.Screen"); final Field screensField = clazz.getDeclaredField("screens"); screensField.setAccessible(true); screensField.set(null, List.of()); return mock(WebEngine.class); }
Example #18
Source File: LocationTools.java From MyBox with Apache License 2.0 | 5 votes |
public static void addMarkerInGaoDeMap(WebEngine webEngine, double longitude, double latitude, String label, String info, String image, boolean multiple, int mapSize, int markSize, int textSize) { String jsLabel = (label == null || label.trim().isBlank() ? "null" : "'" + label.replaceAll("'", CommonValues.MyBoxSeparator) + "'"); String jsInfo = (info == null || info.trim().isBlank() ? "null" : "'" + info.replaceAll("'", CommonValues.MyBoxSeparator) + "'"); String jsImage = (image == null || image.trim().isBlank() ? "null" : "'" + StringTools.replaceAll(image, "\\", "/") + "'"); webEngine.executeScript("addMarker(" + longitude + "," + latitude + ", " + jsLabel + ", " + jsInfo + ", " + jsImage + ", " + multiple + ", " + mapSize + ", " + markSize + ", " + textSize + ");"); }
Example #19
Source File: WebBrowserController.java From MyBox with Apache License 2.0 | 5 votes |
protected WebEngine initWebEngine() { if (tabControllers == null || tabControllers.isEmpty()) { return null; } for (Tab tab : tabControllers.keySet()) { WebBrowserBoxController c = tabControllers.get(tab); return c.webEngine; } return null; }
Example #20
Source File: OrsonChartsFXDemo.java From jfree-fxdemos with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void start(Stage stage) throws Exception { TabPane tabPane = new TabPane(); Tab tab1 = new Tab(); tab1.setText("Demos"); tab1.setClosable(false); SplitPane sp = new SplitPane(); final StackPane sp1 = new StackPane(); sp1.getChildren().add(createTreeView()); final BorderPane sp2 = new BorderPane(); sp2.setCenter(createChartPane()); sp.getItems().addAll(sp1, sp2); sp.setDividerPositions(0.3f, 0.6f); tab1.setContent(sp); tabPane.getTabs().add(tab1); Tab tab2 = new Tab(); tab2.setText("About"); tab2.setClosable(false); WebView browser = new WebView(); WebEngine webEngine = browser.getEngine(); webEngine.load(getClass().getResource("/org/jfree/chart3d/fx/demo/about.html").toString()); tab2.setContent(browser); tabPane.getTabs().add(tab2); Scene scene = new Scene(tabPane, 1024, 768); stage.setScene(scene); stage.setTitle("Orson Charts JavaFX Demo"); stage.show(); }
Example #21
Source File: HtmlWebView.java From Learn-Java-12-Programming with MIT License | 5 votes |
public void start10(Stage primaryStage) { Text txt = new Text("Enjoy searching the Web!"); WebView wv = new WebView(); WebEngine we = wv.getEngine(); we.load("http://www.google.com"); //wv.setZoom(1.5); /* WebHistory history = we.getHistory(); ObservableList<WebHistory.Entry> entries = history.getEntries(); for(WebHistory.Entry entry: entries){ String url = entry.getUrl(); String title = entry.getTitle(); Date date = entry.getLastVisitedDate(); } */ VBox vb = new VBox(txt, wv); vb.setSpacing(20); vb.setAlignment(Pos.CENTER); vb.setStyle("-fx-font-size: 20px;-fx-background-color: lightblue;"); vb.setPadding(new Insets(10, 10, 10, 10)); Scene scene = new Scene(vb,750,500); primaryStage.setScene(scene); primaryStage.setTitle("JavaFX with the window to another server"); primaryStage.onCloseRequestProperty() .setValue(e -> System.out.println("Bye! See you later!")); primaryStage.show(); }
Example #22
Source File: O365InteractiveJSLogger.java From davmail with GNU General Public License v2.0 | 5 votes |
public static void register(WebEngine webEngine) { try { Class jsObjectClass = Class.forName("netscape.javascript.JSObject"); Method setMemberMethod = jsObjectClass.getDeclaredMethod("setMember", String.class,Object.class); JSObject window = (JSObject) webEngine.executeScript("window"); setMemberMethod.invoke(window, "davmail", new O365InteractiveJSLogger()); webEngine.executeScript("console.log = function(message) { davmail.log(message); }"); } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { LOGGER.info("netscape.javascript.JSObject not available"); } }
Example #23
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 #24
Source File: HyperlinkWebViewSample.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void start(Stage stage) { VBox vbox = new VBox(); Scene scene = new Scene(vbox); stage.setTitle("Hyperlink Sample"); stage.setWidth(570); stage.setHeight(550); selectedImage.setLayoutX(100); selectedImage.setLayoutY(10); final WebView browser = new WebView(); final WebEngine webEngine = browser.getEngine(); for (int i = 0; i < captions.length; i++) { final Hyperlink hpl = hpls[i] = new Hyperlink(captions[i]); final Image image = images[i] = new Image(getClass().getResourceAsStream(imageFiles[i])); hpl.setGraphic(new ImageView(image)); hpl.setFont(Font.font("Arial", 14)); final String url = urls[i]; hpl.setOnAction((ActionEvent e) -> { webEngine.load(url); }); } HBox hbox = new HBox(); hbox.setAlignment(Pos.BASELINE_CENTER); hbox.getChildren().addAll(hpls); vbox.getChildren().addAll(hbox, browser); VBox.setVgrow(browser, Priority.ALWAYS); stage.setScene(scene); stage.show(); }
Example #25
Source File: RFXWebView.java From marathonv5 with Apache License 2.0 | 5 votes |
private void loadScript(WebView webview) { webview.getProperties().put("current_selector", "body"); WebEngine webEngine = webview.getEngine(); JSObject win = (JSObject) webEngine.executeScript("window"); win.setMember("marathon_recorder", RFXWebView.this); webEngine.executeScript(script); }
Example #26
Source File: Java2JavascriptUtils.java From javafxwebview with Apache License 2.0 | 5 votes |
private static void registerBackendObject(final WebEngine webEngine, final String varname, final Object backend) { Map<String, Object> webEngineBridges = backendObjects.get(webEngine); if (webEngineBridges == null){ webEngineBridges = new HashMap<>(); backendObjects.put(webEngine, webEngineBridges); } webEngineBridges.put(varname, backend); }
Example #27
Source File: LoginJavaFXExample.java From restfb-examples with MIT License | 5 votes |
public void start(Stage stage) { // parse arguments appId = getParameters().getRaw().get(0); appSecret = getParameters().getRaw().get(1); WebView webView = new WebView(); WebEngine webEngine = webView.getEngine(); // create the scene stage.setTitle("Facebook Login Example"); // use quite a wide window to handle cookies popup nicely stage.setScene(new Scene(new VBox(webView), 1000, 600, Color.web("#666970"))); stage.show(); // obtain Facebook access token by loading login page DefaultFacebookClient facebookClient = new DefaultFacebookClient(Version.LATEST); String loginDialogUrl = facebookClient.getLoginDialogUrl(appId, SUCCESS_URL, new ScopeBuilder()); webEngine.load(loginDialogUrl + "&display=popup&response_type=code"); webEngine.locationProperty().addListener((property, oldValue, newValue) -> { if (newValue.startsWith(SUCCESS_URL)) { // extract access token CLIENT_LOGGER.debug(newValue); int codeOffset = newValue.indexOf("code="); String code = newValue.substring(codeOffset + "code=".length()); AccessToken accessToken = facebookClient.obtainUserAccessToken( appId, appSecret, SUCCESS_URL, code); // trigger further code's execution consumeAccessToken(accessToken); // close the app as goal was reached stage.close(); } else if ("https://www.facebook.com/dialog/close".equals(newValue)) { throw new IllegalStateException("dialog closed"); } } ); }
Example #28
Source File: MdSlideManager.java From opencards with BSD 2-Clause "Simplified" License | 5 votes |
private static void redirectLinksToBrowser(WebEngine webEngine) { webEngine.getLoadWorker().stateProperty().addListener( (ov, oldState, newState) -> { // adjust link handling if (webEngine.getDocument() == null) return; NodeList nodeList = webEngine.getDocument().getElementsByTagName("a"); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); EventTarget eventTarget = (EventTarget) node; eventTarget.addEventListener("click", evt -> { EventTarget target = evt.getCurrentTarget(); HTMLAnchorElement anchorElement = (HTMLAnchorElement) target; String href = anchorElement.getHref(); //handle opening URL outside JavaFX WebView try { Desktop.getDesktop().browse(new URI(href)); } catch (IOException | URISyntaxException e) { e.printStackTrace(); } evt.preventDefault(); }, false); } }); }
Example #29
Source File: Java2JavascriptUtils.java From javafxwebview with Apache License 2.0 | 5 votes |
private AlertEventHandlerWrapper( WebEngine engine, EventHandler<WebEvent<String>> wrappedHandler) { this.engine = engine; this.wrappedHandler = wrappedHandler; }
Example #30
Source File: HTMLEditorSample.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void start(Stage stage) { stage.setTitle("HTMLEditor Sample"); stage.setWidth(650); stage.setHeight(500); Scene scene = new Scene(new Group()); VBox root = new VBox(); root.setPadding(new Insets(8, 8, 8, 8)); root.setSpacing(5); root.setAlignment(Pos.BOTTOM_LEFT); final HTMLEditor htmlEditor = new HTMLEditor(); htmlEditor.setPrefHeight(245); htmlEditor.setHtmlText(INITIAL_TEXT); final WebView browser = new WebView(); final WebEngine webEngine = browser.getEngine(); ScrollPane scrollPane = new ScrollPane(); scrollPane.getStyleClass().add("noborder-scroll-pane"); scrollPane.setStyle("-fx-background-color: white"); scrollPane.setContent(browser); scrollPane.setFitToWidth(true); scrollPane.setPrefHeight(180); Button showHTMLButton = new Button("Load Content in Browser"); root.setAlignment(Pos.CENTER); showHTMLButton.setOnAction((ActionEvent arg0) -> { webEngine.loadContent(htmlEditor.getHtmlText()); }); root.getChildren().addAll(htmlEditor, showHTMLButton, scrollPane); scene.setRoot(root); stage.setScene(scene); stage.show(); }