use of java.awt.Desktop in project libgdx by libgdx.
the class JglfwNet method openURI.
public boolean openURI(String uri) {
boolean result = false;
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(new URI(uri));
result = true;
} catch (Exception e) {
Gdx.app.error("JglfwNet", "Unable to open URI:" + uri, e);
}
}
}
return result;
}
use of java.awt.Desktop in project javatari by ppeccin.
the class JComboBoxNim method officialWebPageAction.
private void officialWebPageAction() {
if (!Desktop.isDesktopSupported())
return;
try {
Desktop desktop = Desktop.getDesktop();
if (!desktop.isSupported(Desktop.Action.BROWSE))
return;
closeAction();
desktop.browse(new URI(Parameters.OFFICIAL_WEBSITE));
} catch (Exception e) {
// Give up
}
}
use of java.awt.Desktop in project javatari by ppeccin.
the class JComboBoxNim method twitterPageAction.
private void twitterPageAction() {
if (!Desktop.isDesktopSupported())
return;
try {
Desktop desktop = Desktop.getDesktop();
if (!desktop.isSupported(Desktop.Action.BROWSE))
return;
closeAction();
desktop.browse(new URI(Parameters.TWITTER_WEBPAGE));
} catch (Exception e) {
// Give up
}
}
use of java.awt.Desktop in project jadx by skylot.
the class Link method browse.
private void browse() {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Action.BROWSE)) {
try {
desktop.browse(new java.net.URI(url));
return;
} catch (IOException e) {
LOG.debug("Open url error", e);
} catch (URISyntaxException e) {
LOG.debug("Open url error", e);
}
}
}
try {
String os = System.getProperty("os.name").toLowerCase();
if (os.contains("win")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
return;
}
if (os.contains("mac")) {
Runtime.getRuntime().exec("open " + url);
return;
}
Map<String, String> env = System.getenv();
if (env.get("BROWSER") != null) {
Runtime.getRuntime().exec(env.get("BROWSER") + " " + url);
return;
}
} catch (Exception e) {
LOG.debug("Open url error", e);
}
showUrlDialog();
}
use of java.awt.Desktop in project pcgen by PCGen.
the class JIcon method launchFile.
/**
* Launches a file into the appropriate program for the OS we are running on
*/
protected void launchFile() {
if (plugin.isRecognizedFileType(launch)) {
plugin.loadRecognizedFileType(launch);
} else {
boolean opened = false;
// Use desktop if available
if (Desktop.isDesktopSupported()) {
Desktop d = Desktop.getDesktop();
if (d.isSupported(Desktop.Action.OPEN)) {
try {
d.open(launch);
opened = true;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
if (!opened) {
// Unix
if (SystemUtils.IS_OS_UNIX) {
String openCmd;
if (SystemUtils.IS_OS_MAC_OSX) {
// From the command line, the open command acts as if the argument was double clicked from the finder
// (see: man open)
openCmd = "/usr/bin/open";
} else {
// Tries freedesktop.org xdg-open. Quite often installed on Linux/BSD
openCmd = "xdg-open";
}
String filePath = launch.getAbsolutePath();
String[] args = { openCmd, filePath };
Logging.debugPrintLocalised("Runtime.getRuntime().exec: [{0}] [{1}]", args[0], args[1]);
try {
Runtime.getRuntime().exec(args);
} catch (IOException e) {
Logging.errorPrint(e.getMessage(), e);
}
}
//Windows
if (SystemUtils.IS_OS_WINDOWS) {
try {
String start = (" rundll32 url.dll,FileProtocolHandler file://" + launch.getAbsoluteFile());
Runtime.getRuntime().exec(start);
} catch (Exception e) {
Logging.errorPrint(e.getMessage(), e);
}
}
}
}
}
Aggregations