public void actionPerformed(ActionEvent e) { // Launches the UOG website, catches any exceptions

      BrowserLauncher launcher = null;
      try {
        launcher = new BrowserLauncher();
      } catch (BrowserLaunchingInitializingException e1) {
        e1.printStackTrace();
      } catch (UnsupportedOperatingSystemException e1) {
        e1.printStackTrace();
      }
      launcher.openURLinBrowser("http://www.uoguelph.ca");
    }
Example #2
0
  /**
   * open the URL in the users default browser (hopefully)
   *
   * @param url the url to open
   */
  private void openUrl(String url) {

    String errMsg = "Error attempting to launch web browser: ";
    boolean error = true;

    log.debug("Opening URL " + url);

    try {
      final BrowserLauncher launcher = new BrowserLauncher();
      launcher.openURLinBrowser(url);
      error = false;
    } catch (UnsupportedOperatingSystemException e) {
      log.error(e);
      errMsg += e.getLocalizedMessage();
    } catch (BrowserLaunchingInitializingException e) {
      log.error(e);
      errMsg += e.getLocalizedMessage();
    }

    if (error) JOptionPane.showMessageDialog(null, errMsg);
  }