List of usage examples for java.awt Desktop isDesktopSupported
public static boolean isDesktopSupported()
From source file:gui.GW2EventerGui.java
private void jLabelNewVersionMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelNewVersionMousePressed Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { try {// w w w .j ava2 s.co m desktop.browse(new URI("https://sourceforge.net/projects/gw2eventer/files/latest/download")); } catch (Exception e) { e.printStackTrace(); } } }
From source file:com.marginallyclever.makelangelo.MainGUI.java
/** * * @param html String of valid HTML.//from www .j av a 2 s. c o m * @return a */ private JTextComponent createHyperlinkListenableJEditorPane(String html) { final JEditorPane bottomText = new JEditorPane(); bottomText.setContentType("text/html"); bottomText.setEditable(false); bottomText.setText(html); bottomText.setOpaque(false); final HyperlinkListener hyperlinkListener = new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { if (hyperlinkEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(hyperlinkEvent.getURL().toURI()); } catch (IOException | URISyntaxException exception) { // FIXME Auto-generated catch block exception.printStackTrace(); } } } } }; bottomText.addHyperlinkListener(hyperlinkListener); return bottomText; }
From source file:Installer.java
public static JLabel linkify(final String text, String URL, String toolTip) { URI temp = null;/*from w ww. jav a2s . c om*/ 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: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 w w w . j a v a 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:org.bigwiv.blastgraph.gui.BlastGraphFrame.java
private void showHelpContent() { try {/*from w ww . j a v a 2 s .com*/ 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:com.ucuenca.pentaho.plugin.step.EldaPDIStepDialog.java
private void OpenBrowser() { if (Desktop.isDesktopSupported()) { try {/* w w w. j a v a2 s. c o 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() + "/"); } }
From source file:erigo.ctstream.CTstream.java
/** * Callback for menu items and "run time" controls in controlsPanel. * /* ww w . jav a2s . co m*/ * @param eventI The ActionEvent which has occurred. */ @Override public void actionPerformed(ActionEvent eventI) { Object source = eventI.getSource(); if (source == null) { return; } else if (source instanceof JComboBox) { JComboBox<?> fpsCB = (JComboBox<?>) source; framesPerSec = ((Double) fpsCB.getSelectedItem()).doubleValue(); // Even when "change detect" is turned on, we always save an image at a rate which is // the slower of 1.0fps or the current frame rate; this is kind of a "key frame" of // sorts. Because of this, the "change detect" checkbox is meaningless when images/sec // is 1.0 and lower. if (framesPerSec <= 1.0) { changeDetectCheck.setEnabled(false); // A nice side benefit of processing JCheckBox events using an Action listener // is that calling "changeDetectCheck.setSelected(false)" will NOT fire an // event; thus, we maintain our original value of bChangeDetect. changeDetectCheck.setSelected(false); } else { changeDetectCheck.setEnabled(true); changeDetectCheck.setSelected(bChangeDetect); } } else if ((source instanceof JCheckBox) && (((JCheckBox) source) == screencapCheck)) { bScreencap = screencapCheck.isSelected(); if ((writeTask != null) && (writeTask.bIsRunning)) { if (bScreencap) { startScreencapCapture(); } else if (!bScreencap) { stopScreencapCapture(); } } } else if ((source instanceof JCheckBox) && (((JCheckBox) source) == webcamCheck)) { bWebcam = webcamCheck.isSelected(); if ((writeTask != null) && (writeTask.bIsRunning)) { if (bWebcam) { startWebcamCapture(); } else if (!bWebcam) { stopWebcamCapture(); } } } else if ((source instanceof JCheckBox) && (((JCheckBox) source) == audioCheck)) { bAudio = audioCheck.isSelected(); if ((writeTask != null) && (writeTask.bIsRunning)) { if (bAudio) { startAudioCapture(); } else if (!bAudio) { stopAudioCapture(); } } } else if ((source instanceof JCheckBox) && (((JCheckBox) source) == textCheck)) { bText = textCheck.isSelected(); if ((writeTask != null) && (writeTask.bIsRunning)) { if (bText) { startTextCapture(); } else if (!bText) { stopTextCapture(); } } } else if ((source instanceof JCheckBox) && (((JCheckBox) source) == includeMouseCursorCheck)) { if (includeMouseCursorCheck.isSelected()) { bIncludeMouseCursor = true; } else { bIncludeMouseCursor = false; } } else if ((source instanceof JCheckBox) && (((JCheckBox) source) == changeDetectCheck)) { if (changeDetectCheck.isSelected()) { bChangeDetect = true; } else { bChangeDetect = false; } } else if ((source instanceof JCheckBox) && (((JCheckBox) source) == fullScreenCheck)) { if (fullScreenCheck.isSelected()) { bFullScreen = true; // Save the original height guiFrameOrigHeight = guiFrame.getHeight(); // Shrink the GUI down to just controlsPanel Rectangle guiFrameBounds = guiFrame.getBounds(); Rectangle updatedGUIFrameBounds = new Rectangle(guiFrameBounds.x, guiFrameBounds.y, guiFrameBounds.width, controlsPanel.getHeight() + 22); guiFrame.setBounds(updatedGUIFrameBounds); } else { bFullScreen = false; // Expand the GUI to its original height Rectangle guiFrameBounds = guiFrame.getBounds(); int updatedHeight = guiFrameOrigHeight; if (guiFrameOrigHeight == -1) { updatedHeight = controlsPanel.getHeight() + 450; } Rectangle updatedGUIFrameBounds = new Rectangle(guiFrameBounds.x, guiFrameBounds.y, guiFrameBounds.width, updatedHeight); guiFrame.setBounds(updatedGUIFrameBounds); } // To display or not display screencap preview is dependent on whether we are in full screen mode or not. if (screencapStream != null) { screencapStream.updatePreview(); } } else if ((source instanceof JCheckBox) && (((JCheckBox) source) == previewCheck)) { if (previewCheck.isSelected()) { bPreview = true; } else { bPreview = false; } } else if (eventI.getActionCommand().equals("Start")) { // Make sure all needed values have been set String errStr = canCTrun(); if (!errStr.isEmpty()) { JOptionPane.showMessageDialog(guiFrame, errStr, "CTstream settings error", JOptionPane.ERROR_MESSAGE); return; } ((JButton) source).setText("Starting..."); bContinueMode = false; firstCTtime = 0; continueWallclockInitTime = 0; startCapture(); ((JButton) source).setText("Stop"); ((JButton) source).setBackground(Color.RED); continueButton.setEnabled(false); } else if (eventI.getActionCommand().equals("Stop")) { ((JButton) source).setText("Stopping..."); stopCapture(); ((JButton) source).setText("Start"); ((JButton) source).setBackground(Color.GREEN); continueButton.setEnabled(true); } else if (eventI.getActionCommand().equals("Continue")) { // This is just like "Start" except we pick up in time just where we left off bContinueMode = true; firstCTtime = 0; continueWallclockInitTime = 0; startCapture(); startStopButton.setText("Stop"); startStopButton.setBackground(Color.RED); continueButton.setEnabled(false); } else if (eventI.getActionCommand().equals("Settings...")) { boolean bBeenRunning = false; if (startStopButton.getText().equals("Stop")) { bBeenRunning = true; } // Stop capture (if it is running) stopCapture(); startStopButton.setText("Start"); startStopButton.setBackground(Color.GREEN); // Only want to enable the Continue button if the user had in fact been running if (bBeenRunning) { continueButton.setEnabled(true); } // Let user edit settings; the following function will not // return until the user clicks the OK or Cancel button. ctSettings.popupSettingsDialog(); } else if (eventI.getActionCommand().equals("Launch CTweb server...")) { // Pop up dialog to launch the CTweb server new LaunchCTweb(this, guiFrame); } else if (eventI.getActionCommand().equals("CloudTurbine website") || eventI.getActionCommand().equals("View data")) { if (!Desktop.isDesktopSupported()) { System.err.println("\nNot able to launch URL in a browser window, feature not supported."); return; } Desktop desktop = Desktop.getDesktop(); String urlStr = "http://cloudturbine.com"; if (eventI.getActionCommand().equals("View data")) { // v=1 specifies to view 1 sec of data // y=4 specifies 4 grids in y-direction // n=X specifies the number of channels // Setup the channel list String chanListStr = ""; int chanIdx = 0; NumberFormat formatter = new DecimalFormat("00"); if (bWebcam) { chanListStr = chanListStr + "&p" + formatter.format(chanIdx * 10) + "=" + sourceName + "/" + webcamStreamName; ++chanIdx; } if (bAudio) { chanListStr = chanListStr + "&p" + formatter.format(chanIdx * 10) + "=" + sourceName + "/" + audioStreamName; ++chanIdx; } if (bScreencap) { chanListStr = chanListStr + "&p" + formatter.format(chanIdx * 10) + "=" + sourceName + "/" + screencapStreamName; ++chanIdx; } if (bText) { chanListStr = chanListStr + "&p" + formatter.format(chanIdx * 10) + "=" + sourceName + "/" + textStreamName; ++chanIdx; } if (chanIdx == 0) { urlStr = "http://localhost:" + Integer.toString(webScanPort); } else { urlStr = "http://localhost:" + Integer.toString(webScanPort) + "/?dt=1000&c=0&f=false&sm=false&y=4&n=" + Integer.toString(chanIdx) + "&v=1" + chanListStr; } } URI uri = null; try { uri = new URI(urlStr); } catch (URISyntaxException e) { System.err.println("\nURISyntaxException:\n" + e); return; } try { desktop.browse(uri); } catch (IOException e) { System.err.println("\nCaught IOException trying to go to " + urlStr + ":\n" + e); } } else if (eventI.getActionCommand().equals("Exit")) { exit(false); } }
From source file:ca.uviccscu.lp.server.main.MainFrame.java
private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed l.info("Show torrent folder action activated"); File f = new File(SettingsManager.getTorrentFolderPath()); if (f.isDirectory()) { try {//w w w . j a v a2 s . c om if (Desktop.isDesktopSupported()) { l.trace("System supported - opening"); Desktop.getDesktop().open(f); } else { JOptionPane.showMessageDialog(null, "OS is not supported - open manually", "OS error", JOptionPane.WARNING_MESSAGE); } } catch (Exception ex) { l.error("Opening folder exception", ex); } } else { JOptionPane.showMessageDialog(null, "Folder doesn't exist, likely because no games have been hashed", "OS error", JOptionPane.WARNING_MESSAGE); } }
From source file:savant.view.swing.Savant.java
private void initMenu() { loadGenomeItem.setAccelerator(/* w ww .java 2 s . c o m*/ javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_G, MiscUtils.MENU_MASK)); loadFromFileItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, MiscUtils.MENU_MASK)); loadFromURLItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, MiscUtils.MENU_MASK)); loadFromDataSourcePluginItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, MiscUtils.MENU_MASK)); openProjectItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, MiscUtils.MENU_MASK)); saveProjectItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, MiscUtils.MENU_MASK)); saveProjectAsItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, MiscUtils.MENU_MASK | java.awt.event.InputEvent.SHIFT_MASK)); formatItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, MiscUtils.MENU_MASK)); exitItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, MiscUtils.MENU_MASK)); undoItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, MiscUtils.MENU_MASK)); redoItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Y, MiscUtils.MENU_MASK)); bookmarkItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B, MiscUtils.MENU_MASK)); navigationItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.SHIFT_MASK | MiscUtils.MENU_MASK)); panLeftItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_LEFT, java.awt.event.InputEvent.SHIFT_MASK)); panRightItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_RIGHT, java.awt.event.InputEvent.SHIFT_MASK)); zoomInItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_UP, java.awt.event.InputEvent.SHIFT_MASK)); zoomOutItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DOWN, java.awt.event.InputEvent.SHIFT_MASK)); toStartItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_HOME, java.awt.event.InputEvent.SHIFT_MASK)); toEndItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_END, java.awt.event.InputEvent.SHIFT_MASK)); preferencesItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, MiscUtils.MENU_MASK)); crosshairItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_J, MiscUtils.MENU_MASK)); plumblineItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_K, MiscUtils.MENU_MASK)); spotlightItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, MiscUtils.MENU_MASK)); bookmarksItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B, MiscUtils.MENU_MASK | java.awt.event.InputEvent.SHIFT_MASK)); genomeItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, MiscUtils.MENU_MASK | java.awt.event.InputEvent.SHIFT_MASK)); rulerItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, MiscUtils.MENU_MASK | java.awt.event.InputEvent.SHIFT_MASK)); statusBarItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, MiscUtils.MENU_MASK | java.awt.event.InputEvent.SHIFT_MASK)); pluginToolbarItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, MiscUtils.MENU_MASK | java.awt.event.InputEvent.SHIFT_MASK)); exportItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, MiscUtils.MENU_MASK)); if (!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { tutorialsItem.setEnabled(false); userManualItem.setEnabled(false); websiteItem.setEnabled(false); } initBrowseMenu(); try { RecentTracksController.getInstance().populateMenu(recentTrackMenu); RecentProjectsController.getInstance().populateMenu(recentProjectMenu); } catch (IOException ex) { LOG.error("Unable to populate Recent Items menu.", ex); } }
From source file:de.mendelson.comm.as2.client.AS2Gui.java
private void jButtonNewVersionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNewVersionActionPerformed try {//from ww w .j av a 2 s . c o m URI uri = new URI(new URL(this.downloadURLNewVersion).toExternalForm()); if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse(uri); } } catch (Exception e) { this.getLogger().severe(e.getMessage()); } }