Load a URL to WebView
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class Main extends Application {
VBox vb = new VBox();
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) {
vb.setId("root");
WebView browser = new WebView();
WebEngine engine = browser.getEngine();
String url = "http://java2s.com/";
engine.load(url);
vb.setPadding(new Insets(30, 50, 50, 50));
vb.setSpacing(10);
vb.setAlignment(Pos.CENTER);
vb.getChildren().addAll(browser);
Scene scene = new Scene(vb);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Related examples in the same category