java.awt.Desktop#getDesktop ( )源码实例Demo

下面列出了java.awt.Desktop#getDesktop ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MeteoInfo   文件: FrmAbout.java
private void jLabel_webMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel_webMouseClicked
    // TODO add your handling code here:
    try {
        URI uri = new URI("http://www.meteothink.org");
        Desktop desktop = null;
        if (Desktop.isDesktopSupported()) {
            desktop = Desktop.getDesktop();
        }
        if (desktop != null) {
            desktop.browse(uri);
        }
    } catch (URISyntaxException ex) {
        Logger.getLogger(FrmAbout.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ioe) {
    }
}
 
源代码2 项目: MeteoInfo   文件: FrmAbout.java
private void jLabel_webMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel_webMouseClicked
    // TODO add your handling code here:
    try {
        URI uri = new URI("http://www.meteothink.org");
        Desktop desktop = null;
        if (Desktop.isDesktopSupported()) {
            desktop = Desktop.getDesktop();
        }
        if (desktop != null) {
            desktop.browse(uri);
        }
    } catch (URISyntaxException ex) {
        Logger.getLogger(FrmAbout.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ioe) {
    }
}
 
源代码3 项目: DeconvolutionLab2   文件: WebBrowser.java
public static boolean open(String url) {
	Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
	if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
		try {
			desktop.browse(new URL(url).toURI());
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
	JFrame frame = new JFrame("Help");
	JLabel lbl = new JLabel(url);
	frame.add(lbl);
	frame.pack();
	frame.setVisible(true);	
	return false;
}
 
源代码4 项目: jeveassets   文件: DesktopUtil.java
public static void open(final String filename, final Program program) {
	File file = new File(filename);
	LOG.info("Opening: {}", file.getName());
	if (isSupported(Desktop.Action.OPEN)) {
		Desktop desktop = Desktop.getDesktop();
		try {
			desktop.open(file);
			return;
		} catch (IOException ex) {
			LOG.warn("	Opening Failed: {}", ex.getMessage());
		}
	} else {
		LOG.warn("	Opening failed");
	}
	JOptionPane.showMessageDialog(program.getMainWindow().getFrame(), "Could not open " + file.getName(), "Open File", JOptionPane.PLAIN_MESSAGE);
}
 
源代码5 项目: beatoraja   文件: PlayConfigurationView.java
@FXML
public void startTwitterAuth() {
	ConfigurationBuilder cb = new ConfigurationBuilder();
	cb.setOAuthConsumerKey(txtTwitterConsumerKey.getText());
	cb.setOAuthConsumerSecret(txtTwitterConsumerSecret.getText());
	cb.setOAuthAccessToken(null);
	cb.setOAuthAccessTokenSecret(null);
	TwitterFactory twitterfactory = new TwitterFactory(cb.build());
	Twitter twitter = twitterfactory.getInstance();
	try {
		requestToken = twitter.getOAuthRequestToken();
		Desktop desktop = Desktop.getDesktop();
		URI uri = new URI(requestToken.getAuthorizationURL());
		desktop.browse(uri);
		player.setTwitterConsumerKey(txtTwitterConsumerKey.getText());
		player.setTwitterConsumerSecret(txtTwitterConsumerSecret.getText());
		player.setTwitterAccessToken("");
		player.setTwitterAccessTokenSecret("");
		txtTwitterPIN.setDisable(false);
		twitterPINButton.setDisable(false);
		txtTwitterAuthenticated.setVisible(false);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
源代码6 项目: runelite   文件: LinkBrowser.java
private static boolean attemptDesktopOpen(String directory)
{
	if (!Desktop.isDesktopSupported())
	{
		return false;
	}

	final Desktop desktop = Desktop.getDesktop();

	if (!desktop.isSupported(Desktop.Action.OPEN))
	{
		return false;
	}

	try
	{
		desktop.open(new File(directory));
		return true;
	}
	catch (IOException ex)
	{
		log.warn("Failed to open Desktop#open {}", directory, ex);
		return false;
	}
}
 
源代码7 项目: Simple-ADB   文件: SideKick.java
/**
 * to visit a URL address
 */
public static void visitAddress(String adress) {

    try {
        URI uri = new URI(adress);
        Desktop desktop = null;
        if (Desktop.isDesktopSupported()) {
            desktop = Desktop.getDesktop();
        }

        if (desktop != null) desktop.browse(uri);

    } catch (IOException ioe) {
        ioe.printStackTrace();
    } catch (URISyntaxException use) {
        use.printStackTrace();
    }

}
 
源代码8 项目: TinkerTime   文件: Actions.java
@Override
protected void call() throws Exception {
	Desktop desktop = Desktop.getDesktop();
	String message = "mailto:[email protected]?subject=TinkerTime%20Support%20Request";
	URI uri = URI.create(message);
	desktop.mail(uri);
}
 
源代码9 项目: amidst   文件: UpdatePrompt.java
@CalledOnlyBy(AmidstThread.EDT)
private void openURL(URI uri) throws IOException, UnsupportedOperationException {
	if (Desktop.isDesktopSupported()) {
		Desktop desktop = Desktop.getDesktop();
		if (desktop.isSupported(Desktop.Action.BROWSE)) {
			desktop.browse(uri);
		} else {
			throw new UnsupportedOperationException("Unable to open browser page.");
		}
	} else {
		throw new UnsupportedOperationException("Unable to open browser.");
	}
}
 
源代码10 项目: wandora   文件: PalvelukarttaSelector.java
private void openButtonMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_openButtonMouseReleased
    Desktop dt = Desktop.getDesktop();
    if(dt != null) {
        try {
            dt.browse(new URI("http://www.hel.fi/palvelukartta"));
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
}
 
源代码11 项目: Spark   文件: SparkTransferManager.java
/**
 * Launches a file browser or opens a file with java Desktop.open() if is
 * supported
 * 
 * @param file
 */
private void launchFile(File file) {
    if (!Desktop.isDesktopSupported())
        return;
    Desktop dt = Desktop.getDesktop();
    try {
        dt.open(file);
    } catch (IOException ex) {
        launchFile(file.getPath());
    }
}
 
源代码12 项目: proxyee-down   文件: OsUtil.java
public static void openBrowse(String url) throws Exception {
  Desktop desktop = Desktop.getDesktop();
  boolean flag = Desktop.isDesktopSupported() && desktop.isSupported(Desktop.Action.BROWSE);
  if (flag) {
    try {
      URI uri = new URI(url);
      desktop.browse(uri);
    } catch (Exception e) {
      throw new Exception("can't open browse", e);
    }
  } else {
    throw new Exception("don't support browse");
  }
}
 
源代码13 项目: jeveassets   文件: DesktopUtil.java
private static boolean isSupported(final Desktop.Action action) {
	if (Desktop.isDesktopSupported()) {
		Desktop desktop = Desktop.getDesktop();
		if (desktop.isSupported(action)) {
			return true;
		}
	}
	return false;
}
 
源代码14 项目: WorldGrower   文件: CreditsDialog.java
private static void openWebPage(URI uri) {
    Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
    if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
        try {
            desktop.browse(uri);
        } catch (IOException e) {
            throw new IllegalStateException("Problem opening " + uri.toString(), e);
        }
    }
}
 
源代码15 项目: Library-Assistant   文件: LibraryAssistantUtil.java
public static void openFileWithDesktop(File file) {
    try {
        Desktop desktop = Desktop.getDesktop();
        desktop.open(file);
    } catch (IOException ex) {
        Logger.getLogger(LibraryAssistantUtil.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
源代码16 项目: training   文件: ControlsFrame.java
public static boolean openWebpage(URI uri) {
    Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
    if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
        try {
            desktop.browse(uri);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return false;
}
 
源代码17 项目: OpenID-Attacker   文件: HtmlOutput.java
public static void openWebpage(URI uri) {
    Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
    if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
        try {
            desktop.browse(uri);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
源代码18 项目: netbeans   文件: NbApplicationAdapterJDK9.java
static void uninstall() {
    Desktop app = Desktop.getDesktop();

    app.setAboutHandler(null);
    app.setOpenFileHandler(null);
    app.setPreferencesHandler(null);
    app.setQuitHandler(null);
}
 
源代码19 项目: tmc-cli   文件: ExternalUtilTest.java
@Test
public void notSupportedDesktopInOpenInBrowser() throws URISyntaxException {
    URI uri = new URI("http://example.com");
    when(Desktop.isDesktopSupported()).thenReturn(false);
    ExternalsUtil.openInBrowser(uri);

    verifyStatic(never());
    Desktop.getDesktop();
}
 
源代码20 项目: wandora   文件: QueryPanel.java
private void scriptLabelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_scriptLabelMouseReleased
    try {
        Desktop desktop = Desktop.getDesktop();
        desktop.browse(new URI("http://wandora.org/wiki/Query_language"));
    }
    catch(Exception e) {
        e.printStackTrace();
    }
}