Java Code Examples for java.awt.Desktop#browse()

The following examples show how to use java.awt.Desktop#browse() . 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 vote down vote up
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: LinkLabel.java    From java-ocr-api with GNU Affero General Public License v3.0 6 votes vote down vote up
private static void open(URI uri) {
    if (Desktop.isDesktopSupported()) {
        Desktop desktop = Desktop.getDesktop();
        try {
            desktop.browse(uri);
        } catch (IOException e) {
            JOptionPane.showMessageDialog(null,
                    "URL: " + uri,
                    "Please use your browser to visit:", JOptionPane.WARNING_MESSAGE);
        }
    } else {
        JOptionPane.showMessageDialog(null,
                "URL: " + uri,
                "Please use your browser to visit:", JOptionPane.WARNING_MESSAGE);
    }
}
 
Example 3
Source File: WebBrowser.java    From audiveris with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Launches a web browser to browse a site.
 *
 * @param uri URI the browser should open.
 */
public void launch (URI uri)
{
    String osName = System.getProperty("os.name");

    if (true) {
        logger.info("Desktop.browse {} with {} on {}", uri, this, osName);

        try {
            Desktop desktop = Desktop.getDesktop();
            desktop.browse(uri);
        } catch (IOException ex) {
            logger.warn("Could not launch browser " + uri, ex);
        }
    } else {
        // Delegate to BareBonesBrowserLaunch-like code
        logger.info("openURL {} with {} on {}", uri, this, osName);
        openURL(uri.toString());
    }
}
 
Example 4
Source File: FrmAbout.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 5
Source File: MenuSupportAction.java    From HBaseClient with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(ActionEvent arg0)
{
    try
    {
        URI     v_URI     = URI.create(AppMain.$SourceCode);
        Desktop v_Desktop = Desktop.getDesktop();
        
        // 判断系统桌面是否支持要执行的功能
        if ( v_Desktop.isSupported(Desktop.Action.BROWSE) )
        {
            // 获取系统默认浏览器打开链接
            v_Desktop.browse(v_URI);
        }
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}
 
Example 6
Source File: OpenWebLocationInExternalBrowser.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void execute(Wandora wandora, Context context) throws TopicMapException {
    try {
        String location = getWebLocation(context);
        if(location != null && location.length() > 0) {
            Desktop desktop = Desktop.getDesktop();
            desktop.browse(new URI(location));
        }
    }
    catch(Exception ex) {
        log(ex);
    }
}
 
Example 7
Source File: ConsoleWatcher.java    From open-ig with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Open the project issue page. */
void doReport() {
	try {
		Desktop d = Desktop.getDesktop();
		d.browse(new URI(ISSUE_LIST));
	} catch (Throwable ex) {
		doReportDialog();
	}
}
 
Example 8
Source File: PalvelukarttaSelector.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
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 9
Source File: DesktopUtils.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
public static void openWebpage(URI uri) {
	if (isBrowseSupported()) {
		Desktop desktop = Desktop.getDesktop();
		try {
			desktop.browse(uri);
		} catch (Exception e) {
			e.printStackTrace();
		}
	} else {
		System.out.println("Desktop does not support opening of a browser :/ open " + uri + " yourself");
	}
}
 
Example 10
Source File: UtilFunctions.java    From yeti with MIT License 5 votes vote down vote up
public static void launchBrowser(String url) {
    Desktop desktop;
    if (Desktop.isDesktopSupported()) {
        desktop = Desktop.getDesktop();
        try {
            desktop.browse(new URI(url));
        } catch (IOException | URISyntaxException ex) {
            Logger.getLogger("utilFunctions.launchBrowser").log(Level.SEVERE, null, ex);
        }

    }
}
 
Example 11
Source File: RabbitInAHatMain.java    From WhiteRabbit with Apache License 2.0 5 votes vote down vote up
private void doOpenDocumentation() {
	try {
		Desktop desktop = Desktop.getDesktop();
		desktop.browse(new URI(DOCUMENTATION_URL));
	} catch (URISyntaxException | IOException ex) {

	}
}
 
Example 12
Source File: NMapLoaderWindow.java    From NMapGUI with GNU General Public License v3.0 5 votes vote down vote up
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 13
Source File: App.java    From aceql-http with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
    * @param connection
    * @throws SQLException
    * @throws IOException
    */
   public static void openHtmlForConnection(Connection connection) throws SQLException, IOException {
DatabaseMetaData databaseMetaData = connection.getMetaData();
String databaseProductName = databaseMetaData.getDatabaseProductName();

System.out.println(databaseProductName);
System.out.println(SystemUtils.JAVA_VERSION);

System.out.println(new Date() + " Begin...");
File file = new File("c:\\test\\sc.out.html");

SchemaInfoAccessor schemaInfoAccessor = new SchemaInfoAccessor(connection, "sampledb");
System.out.println("schemaInfoAccessor: " + schemaInfoAccessor.isAccessible());

if (schemaInfoAccessor.isAccessible()) {
    SchemaInfoSC schemaInfoSC = schemaInfoAccessor.getSchemaInfoSC();

    String table = null; // customer;
    // table = "orderlog";

    schemaInfoSC.buildOnFile(file, AceQLOutputFormat.html, table);
    System.out.println(schemacrawler.Version.getVersion());

    System.out.println(new Date() + " Done: " + file);
    Desktop desktop = Desktop.getDesktop();
    desktop.browse(file.toURI());

} else {
    System.out.println("Can not get full Schema info: " + schemaInfoAccessor.getFailureReason());
}
   }
 
Example 14
Source File: AboutTab.java    From BurpSuiteHTTPSmuggler with GNU Affero General Public License v3.0 5 votes vote down vote up
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 (Exception e) {
			e.printStackTrace();
		}
	}
}
 
Example 15
Source File: OpenInBrowserAction.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
public static void openURI(URI uri) {
    if (Desktop.isDesktopSupported()) {
        Desktop desktop = Desktop.getDesktop();
        try {
            desktop.browse(uri);
        } catch (IOException e) {
            Messages.showException(e);
        }
    }
}
 
Example 16
Source File: LinktoURL.java    From CPE552-Java with GNU General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    URI uri = new URI("http://www.nytimes.com");
    Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
    if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
        desktop.browse(uri);
    }
}
 
Example 17
Source File: CampaignEditor.java    From open-ig with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Open the help page.
 */
void doHelp() {
	try {
		URI u = new URI("https://github.com/akarnokd/open-ig/wiki/Campaign-editor");
		
		if (Desktop.isDesktopSupported()) {
			Desktop d = Desktop.getDesktop();
			d.browse(u);
		} else {
			JOptionPane.showConfirmDialog(this, u);
		}
	} catch (IOException | URISyntaxException ex) {
		Exceptions.add(ex);
	}
}
 
Example 18
Source File: CreditsDialog.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
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 19
Source File: LinkRunner.java    From collect-earth with MIT License 4 votes vote down vote up
@Override
protected Void doInBackground() throws Exception {
    Desktop desktop = java.awt.Desktop.getDesktop();
    desktop.browse(uri);
    return null;
}
 
Example 20
Source File: OpenCensusMetricsExporterExample.java    From ignite with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    // Setting up prometheus stats collector.
    PrometheusStatsCollector.createAndRegister();

    // Setting up HTTP server that would serve http://localhost:8080 requests.
    HTTPServer srv = new HTTPServer(HOST, PORT, true);

    IgniteConfiguration cfg = new IgniteConfiguration();

    // Setting up OpenCensus exporter.
    OpenCensusMetricExporterSpi openCensusMetricExporterSpi = new OpenCensusMetricExporterSpi();

    // Metrics written to the collector each 1 second.
    openCensusMetricExporterSpi.setPeriod(PERIOD);

    cfg.setMetricExporterSpi(openCensusMetricExporterSpi);

    try (Ignite ignite = Ignition.start(cfg)) {
        // Creating cache.
        IgniteCache<Integer, Integer> cache = ignite.createCache("my-cache");

        // Putting some data to the cache.
        for (int i = 0; i < 100; i++)
            cache.put(i, i);

        // Sleeping for 2 sec to make sure data exported to the prometheus.
        Thread.sleep(2 * PERIOD);

        // If desktop supported opens up page with the metrics.
        if (Desktop.isDesktopSupported()) {
            Desktop desktop = Desktop.getDesktop();

            try {
                desktop.browse(new URI(METRICS_URL));

                Thread.sleep(2 * PERIOD);
            }
            catch (IOException | URISyntaxException e) {
                throw new RuntimeException(e);
            }
        }
        else {
            // In case desktop disabled printing URL content.
            URLConnection conn = new URL(METRICS_URL).openConnection();

            try (InputStream in = conn.getInputStream()) {
                String content = IOUtils.toString(in, conn.getContentEncoding());

                System.out.println(content);
            }
        }
    }
}