Skip to content

Instantly share code, notes, and snippets.

@james-d
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save james-d/531b9d4894f3746f67c0 to your computer and use it in GitHub Desktop.
Save james-d/531b9d4894f3746f67c0 to your computer and use it in GitHub Desktop.
Loading multiple web pages
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