Last active
August 29, 2015 14:19
-
-
Save james-d/531b9d4894f3746f67c0 to your computer and use it in GitHub Desktop.
Loading multiple web pages
This file contains 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 characters
import javafx.application.Application; | |
import javafx.scene.Scene; | |
import javafx.scene.layout.FlowPane; | |
import javafx.scene.web.WebView; | |
import javafx.stage.Stage; | |
public class WebBrowserMultipleLoadingTest extends Application { | |
@Override | |
public void start(Stage primaryStage) { | |
String[] urls = new String[] { | |
"http://www.google.com", | |
"http://stackoverflow.com/questions/29779219/java-fx-loading-multiple-webpages-in-webview-at-a-time", | |
"http://oracle.com", "http://mysql.com", "http://spring.io", | |
"http://r-project.org", "http://tomcat.apache.org" }; | |
FlowPane root = new FlowPane(); | |
for (String url : urls) { | |
WebView webView = new WebView(); | |
webView.getEngine().getLoadWorker().stateProperty().addListener((obs, oldState, newState) -> | |
System.out.println(url + " " + oldState + " -> " + newState)); | |
webView.getEngine().load(url); | |
webView.setMaxSize(400, 400); | |
root.getChildren().add(webView); | |
} | |
Scene scene = new Scene(root, 1200, 1200); | |
primaryStage.setScene(scene); | |
primaryStage.show(); | |
} | |
public static void main(String[] args) { | |
launch(args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment