List of usage examples for javax.swing JOptionPane OK_OPTION
int OK_OPTION
To view the source code for javax.swing JOptionPane OK_OPTION.
Click Source Link
From source file:edu.harvard.mcz.imagecapture.SpecimenDetailsViewPane.java
private JTable getJTableSpecimenParts() { if (jTableSpecimenParts == null) { try {/*from w w w .java 2 s . c o m*/ jTableSpecimenParts = new JTable(new SpecimenPartsTableModel(specimen.getSpecimenParts())); jTableSpecimenParts.getColumnModel().getColumn(0).setPreferredWidth(90); } catch (NullPointerException e) { jTableSpecimenParts = new JTable(new SpecimenPartsTableModel()); jTableSpecimenParts.getColumnModel().getColumn(0).setPreferredWidth(90); } setSpecimenPartsTableCellEditors(); log.debug(specimen.getSpecimenParts().size()); jTableSpecimenParts.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { clickedOnPartsRow = ((JTable) e.getComponent()).getSelectedRow(); jPopupSpecimenParts.show(e.getComponent(), e.getX(), e.getY()); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { clickedOnPartsRow = ((JTable) e.getComponent()).getSelectedRow(); jPopupSpecimenParts.show(e.getComponent(), e.getX(), e.getY()); } } }); jPopupSpecimenParts = new JPopupMenu(); JMenuItem mntmDeleteRow = new JMenuItem("Delete Row"); mntmDeleteRow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { if (clickedOnPartsRow >= 0) { int ok = JOptionPane.showConfirmDialog(thisPane, "Delete the selected preparation?", "Delete Preparation", JOptionPane.OK_CANCEL_OPTION); if (ok == JOptionPane.OK_OPTION) { log.debug("deleting parts row " + clickedOnPartsRow); ((SpecimenPartsTableModel) jTableSpecimenParts.getModel()) .deleteRow(clickedOnPartsRow); setStateToDirty(); } else { log.debug("parts row delete canceled by user."); } } else { JOptionPane.showMessageDialog(thisPane, "Unable to select row to delete."); } } catch (Exception ex) { log.error(ex.getMessage()); JOptionPane.showMessageDialog(thisPane, "Failed to delete a part attribute row. " + ex.getMessage()); } } }); jPopupSpecimenParts.add(mntmDeleteRow); } return jTableSpecimenParts; }
From source file:edu.harvard.mcz.imagecapture.SpecimenDetailsViewPane.java
/** * This method initializes jTable //from w w w . ja v a 2s . c o m * * @return javax.swing.JTable */ private JTable getJTable() { if (jTableNumbers == null) { jTableNumbers = new JTable(new NumberTableModel()); JComboBox<String> jComboNumberTypes = new JComboBox<String>(); jComboNumberTypes.setModel(new DefaultComboBoxModel<String>(NumberLifeCycle.getDistinctTypes())); jComboNumberTypes.setEditable(true); TableColumn typeColumn = jTableNumbers.getColumnModel().getColumn(NumberTableModel.COLUMN_TYPE); DefaultCellEditor comboBoxEditor = new DefaultCellEditor(jComboNumberTypes); //TODO: enable autocomplete for numbertypes picklist. //AutoCompleteDecorator.decorate((JComboBox) comboBoxEditor.getComponent()); typeColumn.setCellEditor(comboBoxEditor); DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText("Click for pick list of number types."); typeColumn.setCellRenderer(renderer); jTableNumbers.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent e) { thisPane.setStateToDirty(); } }); jTableNumbers.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { clickedOnNumsRow = ((JTable) e.getComponent()).getSelectedRow(); jPopupNumbers.show(e.getComponent(), e.getX(), e.getY()); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { clickedOnNumsRow = ((JTable) e.getComponent()).getSelectedRow(); jPopupNumbers.show(e.getComponent(), e.getX(), e.getY()); } } }); jPopupNumbers = new JPopupMenu(); JMenuItem mntmDeleteRow = new JMenuItem("Delete Row"); mntmDeleteRow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { if (clickedOnNumsRow >= 0) { int ok = JOptionPane.showConfirmDialog(thisPane, "Delete the selected number?", "Delete Number", JOptionPane.OK_CANCEL_OPTION); if (ok == JOptionPane.OK_OPTION) { log.debug("deleting numbers row " + clickedOnNumsRow); ((NumberTableModel) jTableNumbers.getModel()).deleteRow(clickedOnNumsRow); setStateToDirty(); } else { log.debug("number row delete canceled by user."); } } else { JOptionPane.showMessageDialog(thisPane, "Unable to select row to delete. Try empting number and type and pressing Save."); } } catch (Exception ex) { log.error(ex.getMessage()); JOptionPane.showMessageDialog(thisPane, "Failed to delete a number row. " + ex.getMessage()); } } }); jPopupNumbers.add(mntmDeleteRow); } return jTableNumbers; }
From source file:com.mirth.connect.client.ui.Frame.java
/** * Adds dependent/dependency dashboard statuses to the given set, based on the type of task * being performed./*w w w. ja va 2s. c o m*/ */ private boolean getStatusesWithDependencies(Set<DashboardStatus> selectedDashboardStatuses, ChannelTask task) { try { ChannelDependencyGraph channelDependencyGraph = new ChannelDependencyGraph( channelPanel.getCachedChannelDependencies()); Set<String> selectedChannelIds = new HashSet<String>(); Set<String> channelIdsToHandle = new HashSet<String>(); Map<String, DashboardStatus> statusMap = new HashMap<String, DashboardStatus>(); for (DashboardStatus dashboardStatus : status) { statusMap.put(dashboardStatus.getChannelId(), dashboardStatus); } // For each selected channel, add any dependent/dependency channels as necessary for (DashboardStatus dashboardStatus : selectedDashboardStatuses) { selectedChannelIds.add(dashboardStatus.getChannelId()); addChannelToTaskSet(dashboardStatus.getChannelId(), channelDependencyGraph, statusMap, channelIdsToHandle, task); } // If additional channels were added to the set, we need to prompt the user if (!CollectionUtils.subtract(channelIdsToHandle, selectedChannelIds).isEmpty()) { ChannelDependenciesWarningDialog dialog = new ChannelDependenciesWarningDialog(task, channelPanel.getCachedChannelDependencies(), selectedChannelIds, channelIdsToHandle); if (dialog.getResult() == JOptionPane.OK_OPTION) { if (dialog.isIncludeOtherChannels()) { for (String channelId : channelIdsToHandle) { selectedDashboardStatuses.add(statusMap.get(channelId)); } } } else { return false; } } } catch (ChannelDependencyException e) { // Should never happen e.printStackTrace(); } return true; }
From source file:CSSDFarm.UserInterface.java
private void btnAddFieldStationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddFieldStationActionPerformed JTextField id = new JTextField(); JTextField name = new JTextField(); //Space is needed to expand dialog JLabel verified = new JLabel(" "); JButton okButton = new JButton("Ok"); JButton cancelButton = new JButton("Cancel"); okButton.setEnabled(false);//from ww w . jav a 2 s . com okButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { String idText = id.getText(); String nameText = name.getText(); addFieldStation(id.getText(), name.getText()); JOptionPane.getRootFrame().dispose(); listUserStations.setSelectedValue(server.getFieldStation(idText), false); } }); cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { JOptionPane.getRootFrame().dispose(); } }); id.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent key) { boolean theid = id.getText().equals(""); boolean thename = name.getText().equals(""); if (server.verifyFieldStation(id.getText()) && !theid && !thename) { verified.setText(" Verified"); verified.setForeground(new Color(0, 102, 0)); okButton.setEnabled(true); } else { verified.setText(" Not Verified"); verified.setForeground(Color.RED); okButton.setEnabled(false); } } }); name.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent key) { boolean theid = id.getText().equals(""); boolean thename = name.getText().equals(""); if (server.verifyFieldStation(id.getText()) && !theid && !thename) { verified.setText(" Verified"); verified.setForeground(new Color(0, 102, 0)); okButton.setEnabled(true); } else { verified.setText(" Not Verified"); verified.setForeground(Color.RED); okButton.setEnabled(false); } } }); Object[] message = { "Field Station ID:", id, "Field Station Name:", name, verified }; int inputFields = JOptionPane.showOptionDialog(null, message, "Add Field Station", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[] { okButton, cancelButton }, null); if (inputFields == JOptionPane.OK_OPTION) { System.out.print("Added Field Station!"); } }
From source file:v800_trainer.JCicloTronic.java
private void jMenuLschenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuLschenActionPerformed // Add your handling code here: int i;// w w w .j av a 2 s.c om int Selection[] = new int[Datentabelle.getSelectedRowCount()]; Selection = Datentabelle.getSelectedRows(); if (JOptionPane.showConfirmDialog(null, "Selektierte Files wirklich Lschen?", "Achtung!", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION) { for (i = 0; i < Datentabelle.getSelectedRowCount(); i++) { DataProperty = new java.util.Properties(); DataProperty.setProperty("Visible", "0"); try { FileOutputStream out = new FileOutputStream(sorter.getValueAt(Selection[i], 5) + ".cfg"); DataProperty.store(out, "Tour ist gelscht"); out.close(); } catch (Exception e) { } ; // file = new File(sorter.getValueAt(Selection[i],5) + ".cfg"); // file.delete(); file = new File(sorter.getValueAt(Selection[i], 5) + ".txt"); file.delete(); } ; ChangeModel(); } ; }
From source file:jeplus.JEPlusFrameMain.java
private void openViewTabForFile(String fn) { // Test if the template file is present File ftmpl = new File(fn); if (!ftmpl.exists()) { JOptionPane.showMessageDialog(this, "<html><p><center>The file " + ftmpl.getPath() + " does not exist.</p>", "File not found", JOptionPane.OK_OPTION); } else {/*from w ww .j a v a 2 s. c o m*/ EPlusTextPanel TextFilePanel = new EPlusTextPanel(TpnEditors, fn, EPlusTextPanel.VIEWER_MODE, EPlusConfig.getFileFilter(EPlusConfig.ALL), ftmpl.getPath(), null); int ti = TpnEditors.getTabCount(); TextFilePanel.setTabId(ti); this.TpnEditors.addTab(fn, TextFilePanel); TpnEditors.setSelectedIndex(ti); TpnEditors.setTabComponentAt(ti, new ButtonTabComponent(TpnEditors, TextFilePanel)); TpnEditors.setToolTipTextAt(ti, ftmpl.getPath()); } }
From source file:it.isislab.dmason.util.SystemManagement.Master.thrower.DMasonMaster.java
private void loadUpdateFile() { String message = "There is no reference worker JAR. Do you want to specify a reference\n " + "JAR for the worker?\n" + "\n" + "If you choose Yes, D-Mason will ensure that every worker is running an\n" + "instance of the reference JAR and update them automatically.\n" + "If you choose No, D-Mason won't perform any check (this is highly\n" + "discouraged as it may lead to unreported errors during the simulation).\n" + "If you choose Cancel, D-Mason will exit.\n\n"; int res = JOptionPane.showConfirmDialog(this, message); if (res == JOptionPane.OK_OPTION) { updateFile = showFileChooser();//from w w w. j a v a2s . c o m if (updateFile != null) { File dest = new File(FTP_HOME + dirSeparator + UPDATE_DIR + dirSeparator + updateFile.getName()); try { FileUtils.copyFile(updateFile, dest); Digester dg = new Digester(DigestAlgorithm.MD5); InputStream in = new FileInputStream(dest); curWorkerDigest = dg.getDigest(in); workerJarName = updateFile.getName(); String fileName = FilenameUtils.removeExtension(updateFile.getName()); dg.storeToPropFile(FTP_HOME + dirSeparator + UPDATE_DIR + dirSeparator + fileName + ".hash"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoDigestFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // else // { // JOptionPane.showMessageDialog(this, "User aborted, D-Mason will now exit."); // this.dispose(); // System.exit(EXIT_ON_CLOSE); // } } else if (res == JOptionPane.NO_OPTION) { enableWorkersUpdate = false; return; } if (updateFile == null || res == JOptionPane.CANCEL_OPTION || res == JOptionPane.CLOSED_OPTION) { JOptionPane.showMessageDialog(this, "User aborted, D-Mason will now exit."); this.dispose(); System.exit(EXIT_ON_CLOSE); } }
From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java
private void btnWeightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWeightActionPerformed Boolean isSave = false;/*from ww w . j a va 2s . c o m*/ String staff = ""; String pass = "NO"; if (this.currentEntry != null) { if (AppHelper.CheckTwoDigit(this.txtWeight.getText())) { if (recordValidationService.Validate(currentEntry, RecordKey.PRODUCT_WEIGHT, Float.parseFloat(this.txtWeight.getText()))) { isSave = true; pass = "YES"; } else { if (!this.txtWeightStaff.getText().equals("")) { isSave = true; } else { JOptionPane.showMessageDialog(this, "the value is not within the range, please entry technician name.", "Warning", JOptionPane.OK_OPTION); this.labWeightStaff.setVisible(true); this.txtWeightStaff.setVisible(true); } } staff = this.txtWeightStaff.getText(); this.txtWeightStaff.setText(""); } else { JOptionPane.showMessageDialog(this, "Please entry the valid number like (123.45).", "Warning", JOptionPane.OK_OPTION); } if (isSave) { DefaultTableModel model = (DefaultTableModel) this.tblWeight.getModel(); Date now = new Date(); String time = new SimpleDateFormat("HH:mm").format(now); Float value = Float.parseFloat(this.txtWeight.getText()); model.addRow(new Object[] { time, value, pass, staff }); ((AbstractTableModel) this.tblWeight.getModel()).fireTableDataChanged(); datasetWeight.addValue(value, "Weight", time); this.labWeightStaff.setVisible(false); this.txtWeightStaff.setVisible(false); this.txtWeight.setText(""); UpdateEntryData(now, value, RecordKey.PRODUCT_WEIGHT, staff, pass, ""); } } }
From source file:com.openbravo.pos.sales.JRetailPanelTicket.java
private void printTicketGeneric(String sresourcename, RetailTicketInfo ticket, Object ticketext) { java.util.List<TicketLineConstructor> allLines = null; java.util.List<TicketLineConstructor> startallLines = new ArrayList<TicketLineConstructor>(); int count = 0; com.openbravo.pos.printer.printer.ImageBillPrinter printer = new ImageBillPrinter(); if (sresourcename.equals("Printer.Bill")) { allLines = getAllLines(ticket, ticketext); } else if (sresourcename.equals("Printer.NonChargableBill")) { allLines = getNonChargeableLines(ticket, ticketext); }/*from w w w .j a v a 2 s . c o m*/ int divideLines = allLines.size() / 48; int remainder = allLines.size() % 48; int value = 48; int k = 0; if (divideLines > 0) { for (int i = 0; i < divideLines; i++) { for (int j = k; j < value; j++) { startallLines.add(new TicketLineConstructor(allLines.get(j).getLine())); } try { printer.print(startallLines); } catch (PrinterException ex) { Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex); } if (allLines.size() > 48) { try { Thread.sleep(5000); } catch (InterruptedException ex) { Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex); } int res = JOptionPane.showConfirmDialog(this, AppLocal.getIntString("message.wannaPrintcontinue"), AppLocal.getIntString("message.title"), JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE); if (res == JOptionPane.OK_OPTION) { k = value; value = value + 48; startallLines = new ArrayList<TicketLineConstructor>(); startallLines.clear(); } else { break; } } } } if (remainder > 0) { startallLines = new ArrayList<TicketLineConstructor>(); startallLines.clear(); for (int m = k; m < k + remainder; m++) { startallLines.add(new TicketLineConstructor(allLines.get(m).getLine())); } try { printer.print(startallLines); } catch (PrinterException ex) { Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java
private void btnWallActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWallActionPerformed Boolean isSave = false;// www.j a v a 2 s . co m String staff = ""; String pass = "NO"; String checker = ""; if (this.currentEntry != null) { if (AppHelper.CheckTwoDigit(this.txtWallBase.getText()) && AppHelper.CheckTwoDigit(this.txtWallHandleBung.getText()) && AppHelper.CheckTwoDigit(this.txtWallClosure.getText()) && AppHelper.CheckTwoDigit(this.txtWallHandleLeft.getText()) && AppHelper.CheckTwoDigit(this.txtWallHandleRight.getText()) && AppHelper.CheckTwoDigit(this.txtWallUnderHandle.getText())) { if (recordValidationService.Validate(currentEntry, RecordKey.WALL_BASE, Float.parseFloat(this.txtWallBase.getText())) && recordValidationService.Validate(currentEntry, RecordKey.WALL_CLOSURE, Float.parseFloat(this.txtWallClosure.getText())) && recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_BUNG, Float.parseFloat(this.txtWallHandleBung.getText())) && recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_LEFT, Float.parseFloat(this.txtWallHandleLeft.getText())) && recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_RIGHT, Float.parseFloat(this.txtWallHandleRight.getText())) && recordValidationService.Validate(currentEntry, RecordKey.WALL_UNDER_HANDLE, Float.parseFloat(this.txtWallUnderHandle.getText()))) { isSave = true; } else { checker = JOptionPane.showInputDialog(this, "the value is not within the range, please entry technician name.", "Warning", JOptionPane.OK_OPTION); if (!checker.equals("")) { isSave = true; } } staff = this.txtWallStaff.getText(); this.txtWallStaff.setText(""); } else { JOptionPane.showMessageDialog(this, "Please entry the valid number like (123.45).", "Warning", JOptionPane.OK_OPTION); } if (isSave) { DefaultTableModel model = (DefaultTableModel) this.tblWall.getModel(); Date now = new Date(); String time = new SimpleDateFormat("HH:mm").format(now); Float valueUnderHandle = Float.parseFloat(this.txtWallUnderHandle.getText()); Float valueBase = Float.parseFloat(this.txtWallBase.getText()); Float valueClosure = Float.parseFloat(this.txtWallClosure.getText()); Float valueHandleBung = Float.parseFloat(this.txtWallHandleBung.getText()); Float valueHandleLeft = Float.parseFloat(this.txtWallHandleLeft.getText()); Float valueHandleRight = Float.parseFloat(this.txtWallHandleRight.getText()); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_UNDER_HANDLE, Float.parseFloat(this.txtWallUnderHandle.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_UNDER_HANDLE, valueUnderHandle, pass, staff }); UpdateEntryData(now, valueUnderHandle, RecordKey.WALL_UNDER_HANDLE, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_BASE, Float.parseFloat(this.txtWallBase.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_BASE, valueBase, "YES", staff }); UpdateEntryData(now, valueBase, RecordKey.WALL_BASE, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_CLOSURE, Float.parseFloat(this.txtWallClosure.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_CLOSURE, valueClosure, pass, staff }); UpdateEntryData(now, valueClosure, RecordKey.WALL_CLOSURE, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_BUNG, Float.parseFloat(this.txtWallHandleBung.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_HANDLE_BUNG, valueHandleBung, pass, staff }); UpdateEntryData(now, valueHandleBung, RecordKey.WALL_HANDLE_BUNG, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_LEFT, Float.parseFloat(this.txtWallHandleLeft.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_HANDLE_LEFT, valueHandleLeft, pass, staff }); UpdateEntryData(now, valueHandleLeft, RecordKey.WALL_HANDLE_LEFT, staff, pass, ""); if (recordValidationService.Validate(currentEntry, RecordKey.WALL_HANDLE_RIGHT, Float.parseFloat(this.txtWallHandleRight.getText()))) { pass = "YES"; } else { pass = "NO(" + checker + ")"; } model.addRow(new Object[] { time, RecordKey.WALL_HANDLE_RIGHT, valueHandleRight, pass, staff }); UpdateEntryData(now, valueHandleRight, RecordKey.WALL_HANDLE_RIGHT, staff, pass, ""); ((AbstractTableModel) this.tblWall.getModel()).fireTableDataChanged(); this.txtWallUnderHandle.setText(""); this.txtWallBase.setText(""); this.txtWallClosure.setText(""); this.txtWallHandleBung.setText(""); this.txtWallHandleLeft.setText(""); this.txtWallHandleRight.setText(""); } } }