package javafxwebviewcrasher; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Application; import javafx.application.Platform; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.layout.HBox; import javafx.scene.layout.StackPane; import javafx.scene.web.WebEngine; import javafx.scene.web.WebView; import javafx.stage.Stage; public class JavaFXWebViewCrasher extends Application { private HBox mainHolder = new HBox(); @Override public void start(Stage primaryStage) { StackPane root = new StackPane(); root.setAlignment(Pos.CENTER); root.getChildren().add(mainHolder); Scene scene = new Scene(root, 1200, 300); primaryStage.setScene(scene); primaryStage.show(); final JavaFXWebViewCrasher thisCrasher = this; new Thread("youTubeControllerThread") { public void run() { while (true) { try { Platform.runLater(new Runnable() { @Override public void run() { thisCrasher.clearAndSetYoutube(); } }); Thread.sleep(1000 * 30); } catch (InterruptedException ex) { Logger.getLogger(JavaFXWebViewCrasher.class.getName()).log(Level.SEVERE, null, ex); } } } }.start(); } private void clearAndSetYoutube() { mainHolder.getChildren().clear(); String youtubeEmbedString = ""+ ""+ " " + "
"+ " " + "
" + " "+ " "+ ""; for (int i = 0; i < 5; i++) { WebView webView = new WebView(); WebEngine webEngine = webView.getEngine(); webEngine.loadContent(youtubeEmbedString); mainHolder.getChildren().add(webView); } } public static void main(String[] args) { launch(args); } }