I am trying to open a link from JavaFX. However, attempting to do this purely from JavaFX is not working.
How can I do the following purely in JavaFX This is working for me using java.awt.desktop and I am looking for the same behavior use pure javaFX code.
hyperlink.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
Desktop d = Desktop.getDesktop();
try {
d.browse(new URI(hyperlink.getText()));
} catch (IOException ex) {
Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
} catch (URISyntaxException ex) {
Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
}
//webEngine.load("www.google.com ");
}
});
}
How can I open the link in JavaFX natively?