getHostServices().showDocument() in a FXML File
Is there any easy way to put into the toHomepage() method the getHostServices().showDocument() command somehow, instead of doing lines and lines of code, so the code should look clean and simple? package sample; import javafx.application.HostServices; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; public class Controller { @FXML private Button facebookButton; @FXML void toHomepage(ActionEvent event) { } } If I press the button, it should directly link me to the Facebook URL You need to pass the HostServices to the Controller . Key Code: Set the