List of usage examples for java.awt Desktop isDesktopSupported
public static boolean isDesktopSupported()
From source file:com.wesley.urban_cuts.client.urbancuts.myFrame.java
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed if (Desktop.isDesktopSupported()) { try {//from w ww. j ava2s. c om File myFile = new File( "C:\\Users\\User\\Documents\\NetBeansProjects\\Urban_Cuts_App\\src\\java\\License_agreement.pdf"); Desktop.getDesktop().open(myFile); } catch (IOException ex) { } } }
From source file:com.fratello.longevity.smooth.AppGUI.java
private void openWebPage(String urlName) { try {/*from ww w .jav a2 s . c o 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:de.adv_online.aaa.katalogtool.KatalogDialog.java
public void actionPerformed(ActionEvent e) { if (startButton == e.getSource()) { startTransformation();//from w w w . j av a2 s . c om } 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: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 w w . j a v a 2 s. c o 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); } }
From source file:com._17od.upm.gui.MainWindow.java
private void LaunchSelectedURL(String url) { if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); try {//from www . j a v a 2 s. co m desktop.browse(new URI(url)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Linux and Mac specific code in order to launch url } else { Runtime runtime = Runtime.getRuntime(); try { runtime.exec("xdg-open " + url); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:com.diversityarrays.kdxplore.KDXploreFrame.java
private JMenu createHelpMenu() { JMenu helpMenu = new JMenu(Msg.MENU_HELP()); helpMenu.add(aboutAction);/*from w w w .j a v a 2 s . com*/ if (Desktop.isDesktopSupported()) { helpMenu.add(onlineHelpAction); helpMenu.add(new ReportIssueAction(this)); } return helpMenu; }
From source file:com._17od.upm.gui.AccountDialog.java
/** * Method that get(as input) the selected Account URL and open this URL via * the default browser of our platform./*from w w w . j a va2 s .co m*/ * * @param url */ private void LaunchSelectedURL(String url) { if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); try { desktop.browse(new URI(url)); } catch (IOException e) { e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); } } else { // Linux and Mac specific code in order to launch url Runtime runtime = Runtime.getRuntime(); try { runtime.exec("xdg-open " + url); } catch (IOException e) { e.printStackTrace(); } } }
From source file:ch.algotrader.simulation.SimulationExecutorImpl.java
private void reportStatisticsToFile(SimulationResultVO resultVO) { if (!this.commonConfig.isDisableReports()) { try {// w w w . j a v a 2 s .com File reportLocation = this.commonConfig.getReportLocation(); File reportFile = new File(reportLocation != null ? reportLocation : new File("."), "BackTestReport.csv"); BackTestReport backTestReport = new BackTestReport(reportFile); backTestReport.write("dateTime", DateTimePatterns.LOCAL_DATE_TIME.format(LocalDateTime.now())); backTestReport.write("executionTime", resultVO.getMins()); backTestReport.write("dataSet", this.commonConfig.getDataSet()); if (resultVO.getAllTrades().getCount() == 0) { backTestReport.write("allTradesCount", 0); backTestReport.close(); return; } double netLiqValue = resultVO.getNetLiqValue(); backTestReport.write("netLiqValue", twoDigitFormat.format(netLiqValue)); // monthlyPerformances Collection<PeriodPerformanceVO> monthlyPerformances = resultVO.getMonthlyPerformances(); double maxDrawDownM = 0d; double bestMonthlyPerformance = Double.NEGATIVE_INFINITY; int positiveMonths = 0; int negativeMonths = 0; if ((monthlyPerformances != null)) { for (PeriodPerformanceVO monthlyPerformance : monthlyPerformances) { maxDrawDownM = Math.min(maxDrawDownM, monthlyPerformance.getValue()); bestMonthlyPerformance = Math.max(bestMonthlyPerformance, monthlyPerformance.getValue()); if (monthlyPerformance.getValue() > 0) { positiveMonths++; } else { negativeMonths++; } } } // yearlyPerformances int positiveYears = 0; int negativeYears = 0; Collection<PeriodPerformanceVO> yearlyPerformances = resultVO.getYearlyPerformances(); if ((yearlyPerformances != null)) { for (PeriodPerformanceVO yearlyPerformance : yearlyPerformances) { if (yearlyPerformance.getValue() > 0) { positiveYears++; } else { negativeYears++; } } } if ((monthlyPerformances != null)) { backTestReport.write("posMonths", positiveMonths); backTestReport.write("negMonths", negativeMonths); if ((yearlyPerformances != null)) { backTestReport.write("posYears", positiveYears); backTestReport.write("negYears", negativeYears); } } PerformanceKeysVO performanceKeys = resultVO.getPerformanceKeys(); MaxDrawDownVO maxDrawDownVO = resultVO.getMaxDrawDown(); if (performanceKeys != null && maxDrawDownVO != null) { backTestReport.write("avgM", performanceKeys.getAvgM()); backTestReport.write("stdM", performanceKeys.getStdM()); backTestReport.write("avgY", performanceKeys.getAvgY()); backTestReport.write("stdY", performanceKeys.getStdY()); backTestReport.write("sharpeRatio", performanceKeys.getSharpeRatio()); backTestReport.write("maxMonthlyDrawDown", -maxDrawDownM); backTestReport.write("bestMonthlyPerformance", bestMonthlyPerformance); backTestReport.write("maxDrawDown", maxDrawDownVO.getAmount()); backTestReport.write("maxDrawDownPeriod", maxDrawDownVO.getPeriod() / 86400000); backTestReport.write("colmarRatio", performanceKeys.getAvgY() / maxDrawDownVO.getAmount()); } reportTrades(backTestReport, "winningTrades", resultVO.getWinningTrades(), resultVO.getAllTrades().getCount()); reportTrades(backTestReport, "losingTrades", resultVO.getLoosingTrades(), resultVO.getAllTrades().getCount()); reportTrades(backTestReport, "allTrades", resultVO.getAllTrades(), resultVO.getAllTrades().getCount()); backTestReport.write("returns"); if ((monthlyPerformances != null)) { for (PeriodPerformanceVO monthlyPerformance : monthlyPerformances) { backTestReport.write( DateTimePatterns.LOCAL_DATE .format(DateTimeLegacy.toLocalDate(monthlyPerformance.getDate())), monthlyPerformance.getValue()); } } backTestReport.close(); // make sure BackTestReport.xlsx exists File excelReportFile = new File(reportLocation != null ? reportLocation : new File("."), "BackTestReport.xlsm"); if (!excelReportFile.exists()) { InputStream is = getClass().getResourceAsStream("/BackTestReport.xlsm"); FileUtils.copyInputStreamToFile(is, excelReportFile); } if (this.commonConfig.isOpenBackTestReport()) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().open(excelReportFile); } catch (IOException e) { // no application registered to .xlsm files RESULT_LOGGER.info("BackTestReport available at: " + excelReportFile); } } else { RESULT_LOGGER.info("BackTestReport available at: " + excelReportFile); } } } catch (IOException ex) { LOGGER.error(ex.getMessage(), ex); } } }
From source file:com.edduarte.protbox.core.registry.PReg.java
public void openExplorerFolder(FolderOption folderToOpen) throws IOException { String path = ""; if (folderToOpen.equals(FolderOption.SHARED)) path = pair.getSharedFolderPath(); else if (folderToOpen.equals(FolderOption.PROT)) path = pair.getProtFolderPath(); if (SystemUtils.IS_OS_WINDOWS) { Runtime.getRuntime().exec("explorer " + path); } else if (SystemUtils.IS_OS_MAC_OSX) { Runtime.getRuntime().exec("open " + path); } else {//from w ww . j a va2s . co m if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(new File(path)); } } }
From source file:se.llbit.chunky.renderer.ui.RenderControls.java
private JPanel buildGeneralPane() { JLabel canvasSizeLbl = new JLabel("Canvas size:"); JLabel canvasSizeAdvisory = new JLabel("Note: Actual image size may not be the same as the window size!"); canvasSizeCB.setEditable(true);/*from w w w. j a v a2s .c o m*/ canvasSizeCB.addItem("400x400"); canvasSizeCB.addItem("1024x768"); canvasSizeCB.addItem("960x540"); canvasSizeCB.addItem("1920x1080"); canvasSizeCB.addActionListener(canvasSizeListener); final JTextField canvasSizeEditor = (JTextField) canvasSizeCB.getEditor().getEditorComponent(); canvasSizeEditor.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { } @Override public void focusGained(FocusEvent e) { canvasSizeEditor.selectAll(); } }); updateCanvasSizeField(); loadSceneBtn.setText("Load Scene"); loadSceneBtn.setIcon(Icon.load.imageIcon()); loadSceneBtn.addActionListener(loadSceneListener); JButton loadSelectedChunksBtn = new JButton("Load Selected Chunks"); loadSelectedChunksBtn.setToolTipText("Load the chunks that are currently selected in the map view"); loadSelectedChunksBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { sceneMan.loadChunks(chunky.getWorld(), chunky.getSelectedChunks()); } }); JButton reloadChunksBtn = new JButton("Reload Chunks"); reloadChunksBtn.setIcon(Icon.reload.imageIcon()); reloadChunksBtn.setToolTipText("Reload all chunks in the scene"); reloadChunksBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { sceneMan.reloadChunks(); } }); openSceneDirBtn.setText("Open Scene Directory"); openSceneDirBtn.setToolTipText("Open the directory where Chunky stores scene descriptions and renders"); openSceneDirBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(context.getSceneDirectory()); } } catch (IOException e) { Log.warn("Failed to open scene directory", e); } } }); openSceneDirBtn.setVisible(Desktop.isDesktopSupported()); loadSceneBtn.setToolTipText("This replaces the current scene!"); JButton setCanvasSizeBtn = new JButton("Apply"); setCanvasSizeBtn.setToolTipText("Set the canvas size to the value in the field"); setCanvasSizeBtn.addActionListener(canvasSizeListener); JButton halveCanvasSizeBtn = new JButton("Halve"); halveCanvasSizeBtn.setToolTipText("Halve the canvas width and height"); halveCanvasSizeBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int width = renderMan.scene().canvasWidth() / 2; int height = renderMan.scene().canvasHeight() / 2; setCanvasSize(width, height); } }); JButton doubleCanvasSizeBtn = new JButton("Double"); doubleCanvasSizeBtn.setToolTipText("Double the canvas width and height"); doubleCanvasSizeBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int width = renderMan.scene().canvasWidth() * 2; int height = renderMan.scene().canvasHeight() * 2; setCanvasSize(width, height); } }); JButton makeDefaultBtn = new JButton("Make Default"); makeDefaultBtn.setToolTipText("Make the current canvas size the default"); makeDefaultBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { PersistentSettings.set3DCanvasSize(renderMan.scene().canvasWidth(), renderMan.scene().canvasHeight()); } }); JSeparator sep1 = new JSeparator(); JSeparator sep2 = new JSeparator(); biomeColorsCB.setText("enable biome colors"); updateBiomeColorsCB(); saveDumpsCB.setText("save dump once every "); saveDumpsCB.addActionListener(saveDumpsListener); updateSaveDumpsCheckBox(); String[] frequencyStrings = new String[dumpFrequencies.length]; for (int i = 0; i < dumpFrequencies.length; ++i) { frequencyStrings[i] = Integer.toString(dumpFrequencies[i]); } dumpFrequencyCB.setModel(new DefaultComboBoxModel(frequencyStrings)); dumpFrequencyCB.setEditable(true); dumpFrequencyCB.addActionListener(dumpFrequencyListener); updateDumpFrequencyField(); saveSnapshotsCB.addActionListener(saveSnapshotListener); updateSaveSnapshotCheckBox(); yCutoff.update(); JPanel panel = new JPanel(); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup() .addGroup(layout.createSequentialGroup().addComponent(loadSceneBtn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(openSceneDirBtn)) .addGroup(layout.createSequentialGroup().addComponent(loadSelectedChunksBtn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(reloadChunksBtn)) .addComponent(sep1) .addGroup(layout.createSequentialGroup().addComponent(canvasSizeLbl) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(canvasSizeCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(setCanvasSizeBtn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(makeDefaultBtn)) .addGroup(layout.createSequentialGroup().addComponent(halveCanvasSizeBtn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(doubleCanvasSizeBtn)) .addComponent(canvasSizeAdvisory).addComponent(sep2).addComponent(biomeColorsCB) .addGroup(layout.createSequentialGroup().addComponent(saveDumpsCB) .addComponent(dumpFrequencyCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(dumpFrequencyLbl).addGap(0, 0, Short.MAX_VALUE)) .addComponent(saveSnapshotsCB).addGroup(yCutoff.horizontalGroup(layout))) .addContainerGap()); layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup().addComponent(loadSceneBtn).addComponent(openSceneDirBtn)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(layout .createParallelGroup().addComponent(loadSelectedChunksBtn).addComponent(reloadChunksBtn)) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent( sep1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(canvasSizeLbl) .addComponent(canvasSizeCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(setCanvasSizeBtn).addComponent(makeDefaultBtn)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup().addComponent(halveCanvasSizeBtn) .addComponent(doubleCanvasSizeBtn)) .addPreferredGap(ComponentPlacement.RELATED).addComponent(canvasSizeAdvisory) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(sep2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(biomeColorsCB) .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(saveDumpsCB) .addComponent(dumpFrequencyCB).addComponent(dumpFrequencyLbl)) .addComponent(saveSnapshotsCB).addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(yCutoff.verticalGroup(layout)).addContainerGap()); return panel; }