List of usage examples for java.awt Desktop getDesktop
public static synchronized Desktop getDesktop()
From source file:com.fratello.longevity.smooth.AppGUI.java
private void openWebPage(String urlName) { try {/* w w w. j a va2 s .co m*/ URL u = new URL(urlName); Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) desktop.browse(u.toURI()); } catch (IOException e) { e.printStackTrace(); } catch (URISyntaxException e2) { e2.printStackTrace(); } }
From source file:uiuc.dm.miningTools.ui.ParametersSelectionFrame.java
private void initInterpolationParametersPanel() { interpolationParamsSelectionPanel = new JPanel(); interpolationParamsSelectionPanel//from w w w .j av a 2 s . c om .setPreferredSize(new Dimension(INTERPOLATE_PARAMS_PANEL_WIDTH, INTERPOLATE_PARAMS_PANEL_HEIGHT)); this.interpBox = new JCheckBox("Enable"); this.interpBox.setSelected(true); this.interpBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (interpBox.isSelected()) { interpFlag = true; gapCombo.setEnabled(true); thresGapCombo.setEnabled(true); } else { interpFlag = false; gapCombo.setEnabled(false); thresGapCombo.setEnabled(false); } } } ); //this.interpBox.addChangeListener(null); // interpolationParamsSelectionPanel.add(this.interpLabel); interpolationParamsSelectionPanel.add(this.interpBox); interpolationParamsSelectionPanel.add(gapLabel); interpolationParamsSelectionPanel.add(gapCombo); interpolationParamsSelectionPanel.add(thresGapLabel); interpolationParamsSelectionPanel.add(thresGapCombo); interpolationNextButton = new JButton("Next"); interpolationParamsSelectionPanel.add(interpolationNextButton); interpolationParamsSelectionPanel.add(dataInterpolationHelpButton); interpolationNextButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showPanel(miningFunctionSelectionPanel, MINING_FUNC_SELECTION_PANEL_TITLE); showPanel(displayInstructionPanel); } }); dataInterpolationHelpButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { String workingDir = System.getProperty("user.dir").replace("\\", "/"); Desktop.getDesktop().browse(new URI("file://" + workingDir + "/index.html#interpolate")); } catch (URISyntaxException ex) { Logger.getLogger(ParametersSelectionFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ParametersSelectionFrame.class.getName()).log(Level.SEVERE, null, ex); } } }); hidePanel(interpolationParamsSelectionPanel); }
From source file:cognitivej.vision.overlay.builder.ImageOverlayBuilder.java
/** * Saves the image to the disk and launches the default viewer for images. * * @param file - the file where the image will be saved * @return this/*w w w .j av a 2s . c o m*/ */ @NotNull public ImageOverlayBuilder toDiskAndLaunchViewer(@NotNull File file) { toDisk(file); try { Desktop.getDesktop().open(file); Utils.waitFor(3, TimeUnit.SECONDS); } catch (IOException e) { throw new CognitiveException("Could not open image", e); } return this; }
From source file:de.adv_online.aaa.katalogtool.KatalogDialog.java
public void actionPerformed(ActionEvent e) { if (startButton == e.getSource()) { startTransformation();/* w w w. j a v a 2 s . c o m*/ } else if (e.getSource() == viewLogButton) { try { if (Desktop.isDesktopSupported()) Desktop.getDesktop().open(logfile); else if (SystemUtils.IS_OS_WINDOWS) Runtime.getRuntime().exec("cmd /c start " + logfile.getPath()); else Runtime.getRuntime().exec("open " + logfile.getPath()); } catch (Exception e1) { e1.printStackTrace(); System.exit(1); } } else if (e.getSource() == exitButton) { closeDialog(); } }
From source file:gdt.jgui.entity.webset.JWeblinkEditor.java
/** * Open URL in the default browse.//from w w w. j av a2s . c o m * @param console the main console. * @param locator$ the locator string. */ public void browseUrl(JMainConsole console, String locator$) { try { Properties locator = Locator.toProperties(locator$); String url$ = locator.getProperty(JWeblinksPanel.WEB_LINK_URL); // System.out.println("weblinkEditor:browseUrl:url="+url$); Desktop.getDesktop().browse(new URI(url$)); } catch (Exception ee) { Logger.getLogger(getClass().getName()).info(ee.toString()); } }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
protected void showInfo() { JPanel panel = new JPanel(new BorderLayout()); panel.add(//ww w . j a v a 2s . c om new JLabel( "<html>Kevin Krummenauer 2015<br><br>Icons by http://jonasraskdesign.com<br><br></html>"), BorderLayout.NORTH); JLabel link = new JLabel("Kontakt: " + EMAIL); link.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { openEMail(); } }); link.setCursor(new Cursor(Cursor.HAND_CURSOR)); link.setForeground(Color.BLUE); panel.add(link, BorderLayout.CENTER); JPanel panel2 = new JPanel(new GridLayout(0, 1, 4, 4)); { panel2.add(new JLabel("<html><b>Libraries and its licenses</b> (click to open)</html>"), BorderLayout.NORTH); val list = Arrays.asList( new TwoObjectsX<String, String>("ILIAS Downloader 2", ServiceFunctions.ILIASDOWNLOADER_WEBSITE_LICENSE), new TwoObjectsX<String, String>("Java JDK 8", "http://www.oracle.com/technetwork/java/javase/terms/license/index.html"), new TwoObjectsX<String, String>("Apache Commons IO und Apache Commons Codec", "apache_license.txt"), new TwoObjectsX<String, String>("Project Lombok", "lombok_license.txt"), new TwoObjectsX<String, String>("KSOAP2", "ksoap2_android.txt"), new TwoObjectsX<String, String>("Simple XML Serialization", "apache_license.txt")); for (val lib : list) { link = new JLabel(lib.getObjectA()); if (lib.getObjectB() != null) { link.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { String s = lib.getObjectB(); try { if (s.toLowerCase().startsWith("http")) { Desktop.getDesktop().browse(new URI(s)); } else { showLicense(s); } } catch (Exception e1) { showError("Lizenz nicht gefunden: " + s, e1); } } }); link.setCursor(new Cursor(Cursor.HAND_CURSOR)); link.setForeground(Color.BLUE); } panel2.add(link); } } panel.add(panel2, BorderLayout.SOUTH); JOptionPane.showMessageDialog(mainFrame, panel, "Info " + APP_NAME, JOptionPane.INFORMATION_MESSAGE); }
From source file:uiuc.dm.miningTools.ui.ParametersSelectionFrame.java
private void initMiningFunctionsSelectionPanel() { miningFunctionSelectionPanel = new JPanel(); miningFunctionSelectionPanel.setPreferredSize( new Dimension(MINING_FUNC_SELECTION_PANEL_WIDTH, MINING_FUNC_SELECTION_PANEL_HEIGHT)); miningFunctionSelectionPanel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Mining Function"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); miningFunctionSelectionPanel.add(functionLabel); miningFunctionSelectionPanel.add(functionCombo); miningFunctionSelectionPanel.add(miningFucntionHelpButton); miningFucntionHelpButton.addActionListener(new ActionListener() { @Override/*from ww w . j a v a 2 s . c om*/ public void actionPerformed(ActionEvent e) { try { String workingDir = System.getProperty("user.dir").replace("\\", "/"); Desktop.getDesktop().browse(new URI("file://" + workingDir + "/index.html#functions")); } catch (URISyntaxException ex) { Logger.getLogger(ParametersSelectionFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ParametersSelectionFrame.class.getName()).log(Level.SEVERE, null, ex); } } }); hidePanel(miningFunctionSelectionPanel); }
From source file:gdt.jgui.entity.folder.JFolderPanel.java
/** * Open file in the default system viewer. * @param console the main console.//from w ww. j av a 2 s . c o m * @param locator$ the locator string. */ public void openFile(JMainConsole console, String locator$) { // System.out.println("FolderPanel:openFile:locator::"+locator$); try { Properties locator = Locator.toProperties(locator$); String filePath$ = locator.getProperty(FILE_PATH); File file = new File(filePath$); Desktop.getDesktop().open(file); String requesterResponseLocator$ = locator.getProperty(JRequester.REQUESTER_RESPONSE_LOCATOR); if (requesterResponseLocator$ != null) { byte[] ba = Base64.decodeBase64(requesterResponseLocator$); String responseLocator$ = new String(ba, "UTF-8"); JConsoleHandler.execute(console, responseLocator$); } } catch (Exception e) { LOGGER.severe(e.toString()); } }
From source file:genrsa.GenRSAController.java
/** * Abre el archivo Manual de usuario// w ww . j av a 2s. co m * @param event */ public void help(ActionEvent event) { try { String str = System.getProperty("user.dir") + "/Documentacin/Manual de Usuario.pdf"; File localFile = new File(str); Desktop.getDesktop().open(localFile); } catch (IOException e) { } }
From source file:xtrememp.XtremeMP.java
@Override public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == openMenuItem) { playlistManager.addFilesDialog(true); } else if (source == openURLMenuItem) { String url = JOptionPane.showInputDialog(mainFrame, tr("Dialog.OpenURL.Message"), tr("Dialog.OpenURL"), JOptionPane.INFORMATION_MESSAGE); if (url != null && Utilities.startWithProtocol(url)) { boolean isPlaylistFile = false; for (String ext : PlaylistFileFilter.PlaylistFileExt) { if (url.endsWith(ext)) { isPlaylistFile = true; }/*from w ww. j a v a 2 s . co m*/ } if (isPlaylistFile) { playlistManager.clearPlaylist(); playlistManager.loadPlaylist(url); playlist.begin(); } else { PlaylistItem newPli = new PlaylistItem(url, url, -1, false); playlistManager.add(newPli); playlist.setCursor(newPli); } acOpenAndPlay(); } } else if (source == openPlaylistMenuItem) { playlistManager.openPlaylistDialog(); } else if (source == savePlaylistMenuItem) { playlistManager.savePlaylistDialog(); } else if (source == preferencesMenuItem) { PreferencesDialog preferencesDialog = new PreferencesDialog(audioPlayer, this); preferencesDialog.setVisible(true); } else if (source == exitMenuItem) { exit(); } else if (source == playPauseMenuItem || source == playPauseButton) { acPlayPause(); } else if (source == previousMenuItem || source == previousButton) { acPrevious(); } else if (source == nextMenuItem || source == nextButton) { acNext(); } else if (source == randomizePlaylistMenuItem) { playlistManager.randomizePlaylist(); } else if (source == stopMenuItem || source == stopButton) { acStop(); } else if (source == playlistManagerMenuItem) { if (visualizationManager.isVisible()) { visualizationManager.setDssEnabled(false); CardLayout cardLayout = (CardLayout) (mainPanel.getLayout()); cardLayout.show(mainPanel, Utilities.PLAYLIST_MANAGER); playlistManagerMenuItem.setSelected(true); Settings.setLastView(Utilities.PLAYLIST_MANAGER); } } else if (source == visualizationMenuItem) { if (playlistManager.isVisible()) { visualizationManager.setDssEnabled(true); CardLayout cardLayout = (CardLayout) (mainPanel.getLayout()); cardLayout.show(mainPanel, Utilities.VISUALIZATION_PANEL); visualizationMenuItem.setSelected(true); Settings.setLastView(Utilities.VISUALIZATION_PANEL); } } else if (source == updateMenuItem) { SoftwareUpdate.checkForUpdates(true); SoftwareUpdate.showCheckForUpdatesDialog(); } else if (source == aboutMenuItem) { Object[] options = { tr("Button.Close") }; Desktop desktop = null; if (Desktop.isDesktopSupported()) { desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.BROWSE)) { options = new Object[] { tr("Button.Close"), tr("Button.Website") }; } } StringBuffer message = new StringBuffer(); message.append("<html><b><font color='red' size='5'>").append(tr("Application.title")); message.append("</font></b><br>").append(tr("Application.description")); message.append("<br>Copyright 2005-2014 The Xtreme Media Player Project"); message.append("<br><br><b>").append(tr("Dialog.About.Authors")).append(": </b>") .append(tr("Application.authors")); message.append("<br><b>").append(tr("Dialog.About.Version")).append(": </b>").append(currentVersion); message.append("<br><b>").append(tr("Dialog.About.Codename")).append(": </b>") .append(currentVersion.getCodename()); message.append("<br><b>").append(tr("Dialog.About.ReleaseDate")).append(": </b>") .append(currentVersion.getReleaseDate()); message.append("<br><b>").append(tr("Dialog.About.Homepage")).append(": </b>") .append(tr("Application.homepage")); message.append("<br><br><b>").append(tr("Dialog.About.JavaVersion")).append(": </b>") .append(System.getProperty("java.version")); message.append("<br><b>").append(tr("Dialog.About.JavaVendor")).append(": </b>") .append(System.getProperty("java.vendor")); message.append("<br><b>").append(tr("Dialog.About.JavaHome")).append(": </b>") .append(System.getProperty("java.home")); message.append("<br><b>").append(tr("Dialog.About.OSName")).append(": </b>") .append(System.getProperty("os.name")); message.append("<br><b>").append(tr("Dialog.About.OSArch")).append(": </b>") .append(System.getProperty("os.arch")); message.append("<br><b>").append(tr("Dialog.About.UserName")).append(": </b>") .append(System.getProperty("user.name")); message.append("<br><b>").append(tr("Dialog.About.UserHome")).append(": </b>") .append(System.getProperty("user.home")); message.append("<br><b>").append(tr("Dialog.About.UserDir")).append(": </b>") .append(System.getProperty("user.dir")); message.append("</html>"); int n = JOptionPane.showOptionDialog(mainFrame, message, tr("Dialog.About"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, Utilities.APP_256_ICON, options, options[0]); if (n == 1 && desktop != null) { try { URL url = new URL(tr("Application.homepage")); desktop.browse(url.toURI()); } catch (IOException | URISyntaxException ex) { logger.error(ex.getMessage(), ex); } } } else if (source.equals(playModeRepeatNoneMenuItem)) { playlist.setPlayMode(Playlist.PlayMode.REPEAT_NONE); } else if (source.equals(playModeRepeatOneMenuItem)) { playlist.setPlayMode(Playlist.PlayMode.REPEAT_ONE); } else if (source.equals(playModeRepeatAllMenuItem)) { playlist.setPlayMode(Playlist.PlayMode.REPEAT_ALL); } else if (source.equals(playModeShuffleMenuItem)) { playlist.setPlayMode(Playlist.PlayMode.SHUFFLE); } }