Java Code Examples for java.awt.Desktop#getDesktop()
The following examples show how to use
java.awt.Desktop#getDesktop() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FrmAbout.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
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) { } }
Example 2
Source File: FrmAbout.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
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) { } }
Example 3
Source File: SideKick.java From Simple-ADB with GNU General Public License v3.0 | 6 votes |
/** * 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(); } }
Example 4
Source File: LinkBrowser.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
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; } }
Example 5
Source File: WebBrowser.java From DeconvolutionLab2 with GNU General Public License v3.0 | 6 votes |
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; }
Example 6
Source File: DesktopUtil.java From jeveassets with GNU General Public License v2.0 | 6 votes |
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); }
Example 7
Source File: PlayConfigurationView.java From beatoraja with GNU General Public License v3.0 | 6 votes |
@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(); } }
Example 8
Source File: QueryPanel.java From wandora with GNU General Public License v3.0 | 5 votes |
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(); } }
Example 9
Source File: ExternalUtilTest.java From tmc-cli with MIT License | 5 votes |
@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(); }
Example 10
Source File: NbApplicationAdapterJDK9.java From netbeans with Apache License 2.0 | 5 votes |
static void uninstall() { Desktop app = Desktop.getDesktop(); app.setAboutHandler(null); app.setOpenFileHandler(null); app.setPreferencesHandler(null); app.setQuitHandler(null); }
Example 11
Source File: HtmlOutput.java From OpenID-Attacker with GNU General Public License v2.0 | 5 votes |
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(); } } }
Example 12
Source File: ControlsFrame.java From training with MIT License | 5 votes |
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; }
Example 13
Source File: LibraryAssistantUtil.java From Library-Assistant with Apache License 2.0 | 5 votes |
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); } }
Example 14
Source File: CreditsDialog.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
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); } } }
Example 15
Source File: DesktopUtil.java From jeveassets with GNU General Public License v2.0 | 5 votes |
private static boolean isSupported(final Desktop.Action action) { if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(action)) { return true; } } return false; }
Example 16
Source File: OsUtil.java From proxyee-down with Apache License 2.0 | 5 votes |
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"); } }
Example 17
Source File: SparkTransferManager.java From Spark with Apache License 2.0 | 5 votes |
/** * 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()); } }
Example 18
Source File: PalvelukarttaSelector.java From wandora with GNU General Public License v3.0 | 5 votes |
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(); } } }
Example 19
Source File: UpdatePrompt.java From amidst with GNU General Public License v3.0 | 5 votes |
@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."); } }
Example 20
Source File: Actions.java From TinkerTime with GNU General Public License v3.0 | 5 votes |
@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); }