Java Swing Tutorial - Java Desktop .isSupported (Desktop .Action action)








Syntax

Desktop.isSupported(Desktop.Action action) has the following syntax.

public boolean isSupported(Desktop.Action action)

Example

In the following code shows how to use Desktop.isSupported(Desktop.Action action) method.

import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
//  w  ww  .j a va2s .co m
public class Main {
  public static void main(String[] a) {
    try {
      URI uri = new URI("http://www.java2s.com");
      Desktop desktop = null;
      if (Desktop.isDesktopSupported()) {
        desktop = Desktop.getDesktop();
        desktop.isSupported(Desktop.Action.PRINT);
      }

      if (desktop != null)
        desktop.browse(uri);
    } catch (IOException ioe) {
      ioe.printStackTrace();
    } catch (URISyntaxException use) {
      use.printStackTrace();
    }

  }
}