Example usage for java.awt Desktop isSupported

List of usage examples for java.awt Desktop isSupported

Introduction

In this page you can find the example usage for java.awt Desktop isSupported.

Prototype

public boolean isSupported(Action action) 

Source Link

Document

Tests whether an action is supported on the current platform.

Usage

From source file:base.BasePlayer.Main.java

public static void gotoURL(String url) {

    if (!java.awt.Desktop.isDesktopSupported()) {

        System.err.println("Desktop is not supported");
        System.exit(1);/*from w w  w .j  a va2 s .  c o  m*/
    }

    java.awt.Desktop desktop = java.awt.Desktop.getDesktop();

    if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {

        System.err.println("Desktop doesn't support the browse action");
        System.exit(1);
    }

    try {

        java.net.URI uri = new java.net.URI(url);
        desktop.browse(uri);
    } catch (Exception ex) {
        Main.showError("Can not open URL.", "Error");
        //System.err.println( ex.getMessage() );
        ex.printStackTrace();
    }
}