Example usage for java.awt Desktop getDesktop

List of usage examples for java.awt Desktop getDesktop

Introduction

In this page you can find the example usage for java.awt Desktop getDesktop.

Prototype

public static synchronized Desktop getDesktop() 

Source Link

Document

Returns the Desktop instance of the current desktop context.

Usage

From source file:com.farouk.projectapp.FirstGUI.java

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
    jPanel10.setVisible(true);//from ww w  .  j  ava2  s  .  c o m
    StringBuilder temp = new StringBuilder();
    int row = jTable2.getSelectedRow();
    String name = (jTable2.getModel().getValueAt(row, 0).toString());
    for (YahooNews y : YahooNews.getRss(SQLConnect.getSymbolOfCompanyFromDB(name))) {
        temp.append(y.toString());
    }
    jEditorPane1.setContentType("text/html");
    jEditorPane1.setText(temp.toString());
    jEditorPane1.setCaretPosition(0);
    jEditorPane1.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
                System.out.println(e.getURL());
                Desktop desktop = Desktop.getDesktop();
                try {
                    desktop.browse(e.getURL().toURI());
                } catch (Exception ex) {
                    System.err.println("Problem in link click.\n" + ex);
                }
            }
        }
    });

    jEditorPane1.setEditable(false);

}

From source file:neembuu.uploader.NeembuuUploader.java

private void forumButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_forumButtonActionPerformed
    try {//from ww w.j a  va  2 s .  co  m
        Desktop.getDesktop().browse(new URI("http://neembuu.com/uploader/forum/"));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Installer.java

public static JLabel linkify(final String text, String URL, String toolTip) {
    URI temp = null;/*  w w  w.  j a va2 s. c o m*/
    try {
        temp = new URI(URL);
    } catch (Exception e) {
        e.printStackTrace();
    }
    final URI uri = temp;
    final JLabel link = new JLabel();
    link.setText("<HTML><FONT color=\"#000099\">" + text + "</FONT></HTML>");
    if (!toolTip.equals(""))
        link.setToolTipText(toolTip);
    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
    link.addMouseListener(new MouseListener() {
        public void mouseExited(MouseEvent arg0) {
            link.setText("<HTML><FONT color=\"#000099\">" + text + "</FONT></HTML>");
        }

        public void mouseEntered(MouseEvent arg0) {
            link.setText("<HTML><FONT color=\"#000099\"><U>" + text + "</U></FONT></HTML>");
        }

        public void mouseClicked(MouseEvent arg0) {
            if (Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(uri);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                JOptionPane pane = new JOptionPane("Could not open link.");
                JDialog dialog = pane.createDialog(new JFrame(), "");
                dialog.setVisible(true);
            }
        }

        public void mousePressed(MouseEvent e) {
        }

        public void mouseReleased(MouseEvent e) {
        }
    });
    return link;
}

From source file:neembuu.uploader.NeembuuUploader.java

private void donateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_donateButtonActionPerformed
    try {/*from  w ww  . j a  v a  2 s.  c om*/
        Desktop.getDesktop().browse(new URI("http://neembuu.com/uploader/donate/"));
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:neembuu.uploader.NeembuuUploader.java

private void fbbuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fbbuttonActionPerformed
    try {/*  w  w  w. java2  s . c  om*/
        Desktop.getDesktop().browse(new URI("https://facebook.com/NeembuuUploader"));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.bibisco.servlet.BibiscoServlet.java

public void exportProject(HttpServletRequest pRequest, HttpServletResponse pResponse) throws IOException {
    mLog.debug("Start exportProject(HttpServletRequest, HttpServletResponse)");

    ExportType lExportType = ExportType.valueOf(pRequest.getParameter("type"));

    List<File> lListFile = null;
    switch (lExportType) {
    case ARCHIVE:
        lListFile = new ArrayList<File>();
        lListFile.add(ProjectManager.exportProjectAsArchive());
        break;//from www .  j  ava 2  s .  c o m
    case PDF:
        lListFile = ProjectManager.exportProjectAsPdf();
        break;
    case WORD:
        lListFile = ProjectManager.exportProjectAsWord();
        break;

    default:
        break;
    }

    // open folder in file system
    if (Desktop.isDesktopSupported()) {
        try {
            Desktop.getDesktop().open(lListFile.get(0).getParentFile());
        } catch (Exception e) {
            mLog.error(e);
        }
    }

    JSONObject lJSONObject;
    try {
        lJSONObject = new JSONObject();
        JSONArray lJSONArrayFiles = new JSONArray();
        for (int j = 0; j < lListFile.size(); j++) {
            JSONObject lJSONObjectFile = new JSONObject();
            lJSONObjectFile.put("filepath", lListFile.get(j).getAbsolutePath());
            lJSONArrayFiles.put(j, lJSONObjectFile);
        }
        lJSONObject.put("files", lJSONArrayFiles);
    } catch (JSONException e) {
        mLog.error(e);
        throw new BibiscoException(e, BibiscoException.FATAL);
    }

    pResponse.setContentType("application/json; charset=UTF-8");
    Writer lWriter = pResponse.getWriter();
    lWriter.write(lJSONObject.toString());

    mLog.debug("End exportProject(HttpServletRequest, HttpServletResponse)");
}

From source file:com.haulmont.cuba.desktop.sys.DesktopWindowManager.java

@Override
public void showWebPage(String url, @Nullable Map<String, Object> params) {
    try {//from   w  w w .  jav  a 2 s .co  m
        Desktop.getDesktop().browse(new URI(url));
    } catch (IOException | URISyntaxException e) {
        throw new RuntimeException("Unable to show web page " + url, e);
    }
}

From source file:org.bigwiv.blastgraph.gui.BlastGraphFrame.java

private void showHelpContent() {

    try {//from   w w w. j a  v a 2s.  c  o  m
        URI helpLink = new URI("https://github.com/bigwiv/BlastGraph/blob/master/doc/BlastGraph_Manual.md");
        Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
        if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
            desktop.browse(helpLink);
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:de.mendelson.comm.as2.client.AS2Gui.java

private void jMenuItemHelpForumActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemHelpForumActionPerformed
    try {//from  w ww. j a  va 2 s .  c  om
        URI uri = new URI("http://community.mendelson-e-c.com/forum/as2");
        Desktop.getDesktop().browse(uri);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.ucuenca.pentaho.plugin.step.EldaPDIStepDialog.java

private void OpenBrowser() {

    if (Desktop.isDesktopSupported()) {
        try {/*ww w. j ava 2s  .  co  m*/
            Desktop.getDesktop().browse(new URI("http://localhost:" + meta.getPortName() + "/"));
        } catch (IOException e) {

            e.printStackTrace();
        } catch (URISyntaxException e) {

            e.printStackTrace();
        }
    } else {
        openUrlInBrowser("http://localhost:" + meta.getPortName() + "/");

    }

}