Last active
December 14, 2016 00:51
-
-
Save micheljung/834df7b44d6ac538c85eff28be0da6ce to your computer and use it in GitHub Desktop.
Revisions
-
micheljung revised this gist
Dec 14, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,7 @@ public static void main(String[] args) { @Override public void start(Stage primaryStage) throws Exception { testNumber = new AtomicInteger(); WebView webView = new WebView(); engine = webView.getEngine(); engine.loadContent("<!DOCTYPE html>\n" + -
micheljung revised this gist
Dec 14, 2016 . No changes.There are no files selected for viewing
-
micheljung revised this gist
Dec 14, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ public class WebViewBug extends Application { private WebEngine engine; private AtomicInteger testNumber; public static void main(String[] args) { launch(args); @@ -42,7 +42,7 @@ public void start(Stage primaryStage) throws Exception { Timeline timeline = new Timeline( new KeyFrame(Duration.millis(200), (actionEvent) -> append(("<div class=\"row\">Test " + String.valueOf(testNumber.incrementAndGet()) + "</div>"))) ); timeline.setCycleCount(-1); -
micheljung revised this gist
Dec 14, 2016 . No changes.There are no files selected for viewing
-
micheljung created this gist
Dec 13, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.application.Application; import javafx.concurrent.Worker.State; import javafx.scene.Scene; import javafx.scene.web.WebEngine; import javafx.scene.web.WebView; import javafx.stage.Stage; import javafx.util.Duration; import netscape.javascript.JSObject; import java.util.concurrent.atomic.AtomicInteger; public class WebViewBug extends Application { private WebEngine engine; private AtomicInteger restNumber; public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) throws Exception { restNumber = new AtomicInteger(); WebView webView = new WebView(); engine = webView.getEngine(); engine.loadContent("<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + " <style type=\"text/css\">\n" + " .row:nth-child(odd) {\n" + " background: #ccc;\n" + " }\n" + " </style>\n" + "</head>\n" + "<body id=\"content\">\n" + "</body>\n" + "</html>"); primaryStage.setScene(new Scene(webView, 100, 100)); primaryStage.show(); Timeline timeline = new Timeline( new KeyFrame(Duration.millis(200), (actionEvent) -> append(("<div class=\"row\">Test " + String.valueOf(restNumber.incrementAndGet()) + "</div>"))) ); timeline.setCycleCount(-1); engine.getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> { if (newValue == State.SUCCEEDED) { timeline.playFromStart(); } }); } private void append(String html) { ((JSObject) engine.executeScript("document.getElementById('content')")) .call("insertAdjacentHTML", "beforeend", html); engine.executeScript("window.scrollTo(0, document.documentElement.scrollHeight);"); } }