I am writing an application using JavaFX. There will be a button, when clicked, the default browser should open and start loading the page you need. What is the best way to do this?

    1 answer 1

    public class SomeClass extends Application { @Override public void start(Stage primaryStage) { Button btn = new Button(); btn.setText("Open some site"); btn.setOnAction((ActionEvent event) -> { getHostServices().showDocument("http://www.somesite.com"); }); VBox root = new VBox(); root.getChildren().addAll(btn); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); } }