Java Code Examples for javafx.application.HostServices#showDocument()

The following examples show how to use javafx.application.HostServices#showDocument() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PdfsamApp.java    From pdfsam with GNU Affero General Public License v3.0 7 votes vote down vote up
@EventListener
public void openUrl(OpenUrlRequest event) {
    HostServices services = getHostServices();
    if (nonNull(services)) {
        try {
            services.showDocument(event.getUrl());
        } catch (NullPointerException npe) {
            // service delegate can be null but there's no way to check it first so we have to catch the npe
            LOG.info("Unable to open url using HostServices, trying fallback");
            try {
                Runtime.getRuntime().exec(getOpenCmd(event.getUrl()));
            } catch (IOException e) {
                LOG.warn("Unable to open the url", e);
            }
        }
    } else {
        LOG.warn("Unable to open '{}', please copy and paste the url to your browser.", event.getUrl());
    }
}
 
Example 2
Source File: MZmineGUI.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void openWebPage(URL url) {
  HostServices openWPService = getHostServices();
  openWPService.showDocument(String.valueOf(url));
}