There are 1 code examples for java.awt.Desktop.

The API names are highlighted below. You can use suckoo button to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.

Project Name: rmoffice Package: net.sf.rmoffice.ui.actions

Source Code: DesktopAction.java (Click to view .java file)

Method Code:
vote
like

public void doPerform(){
  if (!java.awt.Desktop.isDesktopSupported()) {
    log.error("Desktop is not supported (fatal)");
  }
 else {
    final java.awt.Desktop desktop=java.awt.Desktop.getDesktop();
    Action actionType=Action.BROWSE;
    if (file != null) {
      actionType=Action.OPEN;
    }
    if (!desktop.isSupported(actionType)) {
      log.error("Desktop doesn't support the " + actionType.name() + " action (fatal)");
    }
 else {
      try {
        if (uri != null) {
          desktop.browse(uri);
        }
 else         if (file != null) {
          desktop.open(file);
        }
      }
 catch (      Exception e1) {
        log.error(e1.getMessage());
      }
    }
  }
}