List of usage examples for java.awt Desktop getDesktop
public static synchronized Desktop getDesktop()
From source file:erigo.ctstream.CTstream.java
/** * Callback for menu items and "run time" controls in controlsPanel. * /*from w w w. j a va 2 s .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:savant.view.swing.Savant.java
private void initMenu() { loadGenomeItem.setAccelerator(/* ww w . j ava 2 s . co 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: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 a 2 s. co m 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:org.gtdfree.GTDFree.java
/** * This method initializes jMenu /*ww w. j a va2s . c om*/ * * @return javax.swing.JMenu */ private JMenu getHelpMenu() { if (helpMenu == null) { helpMenu = new JMenu(); helpMenu.setText(Messages.getString("GTDFree.Help")); //$NON-NLS-1$ JMenuItem jmi = new JMenuItem(Messages.getString("GTDFree.Help.Home")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_browser)); jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { URI uri; try { uri = new URI(getEngine().getConfiguration().getProperty("home.url", //$NON-NLS-1$ "http://gtd-free.sourceforge.net")); //$NON-NLS-1$ Desktop.getDesktop().browse(uri); } catch (Exception e1) { Logger.getLogger(this.getClass()).error("URL load failed.", e1); //$NON-NLS-1$ } } }); helpMenu.add(jmi); jmi = new JMenuItem(Messages.getString("GTDFree.Help.Manuals")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_browser)); jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { URI uri; try { uri = new URI(getEngine().getConfiguration().getProperty("manuals.url", //$NON-NLS-1$ "http://gtd-free.sourceforge.net/manuals.html")); //$NON-NLS-1$ //$NON-NLS-3$ Desktop.getDesktop().browse(uri); } catch (Exception e1) { Logger.getLogger(this.getClass()).error("URL load failed.", e1); //$NON-NLS-1$ } } }); helpMenu.add(jmi); jmi = new JMenuItem(getActionMap().get("importDialog")); //$NON-NLS-1$ helpMenu.add(jmi); helpMenu.add(new JSeparator()); jmi = new JMenuItem(); jmi.setText(Messages.getString("GTDFree.Check")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_update)); jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new Thread() { @Override public void run() { checkForUpdates(true); } }.start(); } }); helpMenu.add(jmi); JCheckBoxMenuItem jcbmi = new JCheckBoxMenuItem(); jcbmi.setText(Messages.getString("GTDFree.CheckAtStartup")); //$NON-NLS-1$ try { getEngine().getGlobalProperties().connectBooleanProperty(GlobalProperties.CHECK_FOR_UPDATE_AT_START, jcbmi, "selected", "isSelected", "setSelected", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } catch (Exception e1) { logger.debug("Internal error.", e1); //$NON-NLS-1$ } helpMenu.add(jcbmi); helpMenu.add(new JSeparator()); jmi = new JMenuItem(); jmi.setText(Messages.getString("GTDFree.Help.Mon")); //$NON-NLS-1$ jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getMonitor().getDialog().setVisible(true); } }); helpMenu.add(jmi); helpMenu.add(new JSeparator()); helpMenu.add(getAboutMenuItem()); } return helpMenu; }
From source file:de.mendelson.comm.as2.client.AS2Gui.java
private void jButtonNewVersionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNewVersionActionPerformed try {//www.j a v a 2s. 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()); } }
From source file:Report_PRCR_New_EPF_Excel_File_Generator.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed try {//from w w w . j a v a2 s .c o m DatabaseManager dbm = DatabaseManager.getDbCon(); Date_Handler dt = new Date_Handler(); String year = yearfield.getText(); String month = dt.return_month_as_num(monthfield.getText()); String employee_detail_file_location; if (mv.SoftwareVersion() == 1) { employee_detail_file_location = dbm.checknReturnData("file_locations", "id", "11", "location") + "/" + year + month + ".xls"; System.out.println(employee_detail_file_location); copyFileUsingApacheCommonsIO( new File(dbm.checknReturnData("file_locations", "id", "10", "location")), new File(employee_detail_file_location)); } else if (mv.SoftwareVersion() == 2) { employee_detail_file_location = dbm.checknReturnData("file_locations", "id", "12", "location") + "/" + year + month + ".xls"; System.out.println(employee_detail_file_location); copyFileUsingApacheCommonsIO( new File(dbm.checknReturnData("file_locations", "id", "11", "location")), new File(employee_detail_file_location)); } else { employee_detail_file_location = dbm.checknReturnData("file_locations", "id", "11", "location") + "/" + year + month + ".xls"; System.out.println(employee_detail_file_location); copyFileUsingApacheCommonsIO( new File(dbm.checknReturnData("file_locations", "id", "10", "location")), new File(employee_detail_file_location)); } InputStream inp = new FileInputStream(employee_detail_file_location); Workbook wb = WorkbookFactory.create(inp); org.apache.poi.ss.usermodel.Sheet sheet = wb.getSheetAt(0); String payment_date_year_month_date = null; String table_name = "pr_workdata_" + year + "_" + month; String epf_backup_year_month = year + "_" + month; String previous_table_name = null; if (Integer.parseInt(month) == 1) { previous_table_name = "pr_workdata_" + (Integer.parseInt(year) - 1) + "_" + 12; } else { if ((Integer.parseInt(month) - 1) < 10) { previous_table_name = "pr_workdata_" + year + "_0" + (Integer.parseInt(month) - 1); } else { previous_table_name = "pr_workdata_" + year + "_" + (Integer.parseInt(month) - 1); } } double employee_contribution_percentage = Math.round(Double.parseDouble( dbm.checknReturnData("prcr_new_epf_details", "name", "employee_contribution", "value")) * 100.0) / 100.0; double employer_contribution_percentage = Math.round(Double.parseDouble( dbm.checknReturnData("prcr_new_epf_details", "name", "employer_contribution", "value")) * 100.0) / 100.0; String nic = null; String surname = null; String initials = null; int member_no = 0; double tot_contribution = 0; double employers_contribution = 0; double member_contribution = 0; double tot_earnings = 0; String member_status = null; String zone = null; int employer_number = 0; int contribution_period = 0; int data_submission_no = 0; double no_of_days_worked = 0; int occupation_classification_grade = 0; int payment_mode = 0; int payment_date = 0; String payment_reference = null; int d_o_code = 0; member_status = "E"; zone = dbm.checknReturnData("prcr_new_epf_details", "name", "zone", "value"); employer_number = Integer .parseInt(dbm.checknReturnData("prcr_new_epf_details", "name", "employer_number", "value")); contribution_period = Integer.parseInt(year + month); data_submission_no = 1; occupation_classification_grade = Integer.parseInt(dbm.checknReturnData("prcr_new_epf_details", "name", "occupation_classification_grade", "value")); int normal_days = 0; int sundays = 0; double ot_before = 0; double ot_after = 0; double hours_as_decimal = 0; int count = 0; double total_member_contribution = 0; int need_both_reports = 1; if (chk.isSelected()) { need_both_reports = 0; } else { need_both_reports = 1; } ResultSet query = dbm.query("SELECT * FROM `" + table_name + "` WHERE `register_or_casual` = 1 "); // AND `total_pay` > 0"); while (query.next()) { if (query.getDouble("total_pay") <= 0 && dbm.checkWhetherDataExistsTwoColumns("prcr_epf_etf_backup", "month", epf_backup_year_month, "code", query.getInt("code")) != 1) { continue; } ResultSet query1 = dbm .query("SELECT * FROM `personal_info` WHERE `code` = '" + query.getInt("code") + "' "); while (query1.next()) { nic = query1.getString("nic").replaceAll("\\s+", ""); surname = split_name(query1.getString("name"))[1]; initials = split_name(query1.getString("name"))[0]; member_no = Integer.parseInt(query1.getString("code")); occupation_classification_grade = Integer.parseInt(query1.getString("occupation_grade")); d_o_code = Integer .parseInt(dbm.checknReturnData("prcr_new_epf_details", "name", "d_o_code", "value")); tot_earnings = Math.round(query.getDouble("total_pay") * 100.0) / 100.0; if (dbm.checkWhetherDataExistsTwoColumns("prcr_epf_etf_backup", "month", epf_backup_year_month, "code", member_no) == 1) { tot_earnings = tot_earnings + Double.parseDouble(dbm.checknReturnDatafor2checks("prcr_epf_etf_backup", "month", epf_backup_year_month, "code", member_no, "total_pay")); } employers_contribution = Math.round(tot_earnings * employer_contribution_percentage * 100.0) / 100.0; member_contribution = Math.round(tot_earnings * employee_contribution_percentage * 100.0) / 100.0; tot_contribution = employers_contribution + member_contribution; total_member_contribution = total_member_contribution + tot_contribution; normal_days = query.getInt("normal_days"); sundays = query.getInt("sundays"); /* ot_before = query.getDouble("ot_before_hours"); ot_after = query.getDouble("ot_after_hours"); if ((ot_before + ot_after) > 0) { hours_as_decimal = (ot_before + ot_after) / 100; } else { hours_as_decimal = 0; } if ((normal_days + sundays + hours_as_decimal) > 0) { no_of_days_worked = Math.round((normal_days + sundays + hours_as_decimal) * 100.0) / 100.0; } else { no_of_days_worked = 0; } */ no_of_days_worked = normal_days + sundays; if (dbm.checkWhetherDataExists(previous_table_name, "code", query1.getString("code")) == 1) { member_status = "E"; } else { member_status = "N"; } Row row = sheet.getRow(1 + count); if (row == null) { row = sheet.createRow(1 + count); } for (int k = 0; k < 16; k++) { Cell cell = row.getCell(k); switch (k) { case 0: cell.setCellType(Cell.CELL_TYPE_STRING); cell.setCellValue(nic); break; case 1: cell.setCellType(Cell.CELL_TYPE_STRING); cell.setCellValue(surname); break; case 2: cell.setCellType(Cell.CELL_TYPE_STRING); cell.setCellValue(initials); break; case 3: cell.setCellType(Cell.CELL_TYPE_NUMERIC); cell.setCellValue(member_no); break; case 4: cell.setCellType(Cell.CELL_TYPE_NUMERIC); cell.setCellValue(tot_contribution); break; case 5: cell.setCellType(Cell.CELL_TYPE_NUMERIC); cell.setCellValue(employers_contribution); break; case 6: cell.setCellType(Cell.CELL_TYPE_NUMERIC); cell.setCellValue(member_contribution); break; case 7: cell.setCellType(Cell.CELL_TYPE_NUMERIC); cell.setCellValue(tot_earnings); break; case 8: cell.setCellType(Cell.CELL_TYPE_STRING); cell.setCellValue(member_status); break; case 9: cell.setCellType(Cell.CELL_TYPE_STRING); cell.setCellValue(zone); break; case 10: cell.setCellType(Cell.CELL_TYPE_NUMERIC); cell.setCellValue(employer_number); break; case 11: cell.setCellType(Cell.CELL_TYPE_NUMERIC); cell.setCellValue(contribution_period); break; case 12: cell.setCellType(Cell.CELL_TYPE_NUMERIC); cell.setCellValue(data_submission_no); break; case 13: cell.setCellType(Cell.CELL_TYPE_NUMERIC); cell.setCellValue(no_of_days_worked); break; case 14: cell.setCellType(Cell.CELL_TYPE_NUMERIC); cell.setCellValue(occupation_classification_grade); break; case 15: cell.setCellType(Cell.CELL_TYPE_NUMERIC); cell.setCellValue(d_o_code); break; default: break; } } count++; } query1.close(); } query.close(); FileOutputStream fileOut = new FileOutputStream(employee_detail_file_location); wb.write(fileOut); fileOut.close(); Desktop.getDesktop().open(new File(employee_detail_file_location)); } catch (Exception ex) { System.out.println(ex); msg.showMessage( "Problem Occured.Check whether the Excel file is alredy opened.Please close it and try again..", "Error", "error"); } }
From source file:com.bibisco.servlet.BibiscoServlet.java
public void openUrlExternalBrowser(HttpServletRequest pRequest, HttpServletResponse pResponse) throws IOException { mLog.debug("Start openUrlExternalBrowser(HttpServletRequest, HttpServletResponse)"); String lStrUrl = pRequest.getParameter("url"); mLog.debug("url= ", lStrUrl); if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); try {//from w ww . j ava2s. c om desktop.browse(new URI(lStrUrl)); } catch (Exception e) { mLog.error(e); throw new BibiscoException(e, BibiscoException.IO_EXCEPTION); } } else { Runtime runtime = Runtime.getRuntime(); try { runtime.exec("xdg-open " + lStrUrl); } catch (Exception e) { mLog.error(e); throw new BibiscoException(e, BibiscoException.IO_EXCEPTION); } } pResponse.setContentType("text/html; charset=UTF-8"); Writer lWriter = pResponse.getWriter(); lWriter.write("ok"); mLog.debug("End openUrlExternalBrowser(HttpServletRequest, HttpServletResponse)"); }
From source file:de.mendelson.comm.as2.client.AS2Gui.java
private void jMenuItemHelpShopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemHelpShopActionPerformed try {//from w w w. j a v a 2 s . com URI uri = new URI("http://shop.mendelson-e-c.com"); Desktop.getDesktop().browse(uri); } catch (Exception e) { e.printStackTrace(); } }
From source file:au.org.ala.delta.intkey.Intkey.java
/** * Load the Desktop in the background. We do this because * Desktop.getDesktop() can be very slow *//* ww w . j a v a 2s .c o m*/ private void loadDesktopInBackground() { _desktopWorker = new SwingWorker<Desktop, Void>() { protected Desktop doInBackground() { if (Desktop.isDesktopSupported()) { return Desktop.getDesktop(); } else { return null; } } }; _desktopWorker.execute(); }
From source file:client.welcome2.java
private void SupplierShowContractButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SupplierShowContractButtonActionPerformed try {// w ww. j a v a 2 s . co m Desktop.getDesktop().open(new File(filename_supplier)); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } }