List of usage examples for javax.swing JOptionPane showConfirmDialog
public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType, int messageType) throws HeadlessException
optionType
parameter, where the messageType
parameter determines the icon to display. From source file:com.vgi.mafscaling.VECalc.java
protected void loadLogFile() { fileChooser.setMultiSelectionEnabled(true); if (JFileChooser.APPROVE_OPTION != fileChooser.showOpenDialog(this)) return;// w w w . j a v a 2 s . c o m File[] files = fileChooser.getSelectedFiles(); for (File file : files) { BufferedReader br = null; ArrayDeque<String[]> buffer = new ArrayDeque<String[]>(); try { br = new BufferedReader(new FileReader(file.getAbsoluteFile())); String line = br.readLine(); if (line != null) { String[] elements = line.split("(\\s*)?,(\\s*)?", -1); getColumnsFilters(elements); boolean resetColumns = false; if (logThrottleAngleColIdx >= 0 || logFfbColIdx >= 0 || logSdColIdx >= 0 || (logWbAfrColIdx >= 0 && isOl) || (logStockAfrColIdx >= 0 && !isOl) || (logAfLearningColIdx >= 0 && !isOl) || (logAfCorrectionColIdx >= 0 && !isOl) || logRpmColIdx >= 0 || logMafColIdx >= 0 || logIatColIdx >= 0 || logMpColIdx >= 0) { if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, "Would you like to reset column names or filter values?", "Columns/Filters Reset", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE)) resetColumns = true; } if (resetColumns || logThrottleAngleColIdx < 0 || logFfbColIdx < 0 || logSdColIdx < 0 || (logWbAfrColIdx < 0 && isOl) || (logStockAfrColIdx < 0 && !isOl) || (logAfLearningColIdx < 0 && !isOl) || (logAfCorrectionColIdx < 0 && !isOl) || logRpmColIdx < 0 || logMafColIdx < 0 || logIatColIdx < 0 || logMpColIdx < 0) { ColumnsFiltersSelection selectionWindow = new VEColumnsFiltersSelection(false); if (!selectionWindow.getUserSettings(elements) || !getColumnsFilters(elements)) return; } if (logClOlStatusColIdx == -1) clValue = -1; String[] flds; String[] afrflds; boolean removed = false; int i = 2; int clol = -1; int row = getLogTableEmptyRow(); double thrtlMaxChange2 = thrtlMaxChange + thrtlMaxChange / 2.0; double throttle = 0; double pThrottle = 0; double ppThrottle = 0; double afr = 0; double rpm; double ffb; double iat; clearRunTables(); setCursor(new Cursor(Cursor.WAIT_CURSOR)); for (int k = 0; k <= afrRowOffset && line != null; ++k) { line = br.readLine(); if (line != null) buffer.addFirst(line.split(",", -1)); } try { while (line != null && buffer.size() > afrRowOffset) { afrflds = buffer.getFirst(); flds = buffer.removeLast(); line = br.readLine(); if (line != null) buffer.addFirst(line.split(",", -1)); ppThrottle = pThrottle; pThrottle = throttle; throttle = Double.valueOf(flds[logThrottleAngleColIdx]); try { if (row > 0 && Math.abs(pThrottle - throttle) > thrtlMaxChange) { if (!removed) Utils.removeRow(row--, logDataTable); removed = true; } else if (row <= 0 || Math.abs(ppThrottle - throttle) <= thrtlMaxChange2) { // Filters afr = (isOl ? Double.valueOf(afrflds[logWbAfrColIdx]) : Double.valueOf(afrflds[logStockAfrColIdx])); rpm = Double.valueOf(flds[logRpmColIdx]); ffb = Double.valueOf(flds[logFfbColIdx]); iat = Double.valueOf(flds[logIatColIdx]); if (clValue != -1) clol = Integer.valueOf(flds[logClOlStatusColIdx]); boolean flag = isOl ? ((afr <= afrMax || throttle >= thrtlMin) && afr <= afrMax) : (afrMin <= afr); if (flag && clol == clValue && rpmMin <= rpm && ffbMin <= ffb && ffb <= ffbMax && iat <= iatMax) { removed = false; if (!isOl) trims.add(Double.valueOf(flds[logAfLearningColIdx]) + Double.valueOf(flds[logAfCorrectionColIdx])); Utils.ensureRowCount(row + 1, logDataTable); logDataTable.setValueAt(rpm, row, 0); logDataTable.setValueAt(iat, row, 1); logDataTable.setValueAt(Double.valueOf(flds[logMpColIdx]), row, 2); logDataTable.setValueAt(ffb, row, 3); logDataTable.setValueAt(afr, row, 4); logDataTable.setValueAt(Double.valueOf(flds[logMafColIdx]), row, 5); logDataTable.setValueAt(Double.valueOf(flds[logSdColIdx]), row, 6); row += 1; } else removed = true; } else removed = true; } catch (NumberFormatException e) { logger.error(e); JOptionPane.showMessageDialog(null, "Error parsing number at " + file.getName() + " line " + i + ": " + e, "Error processing file", JOptionPane.ERROR_MESSAGE); return; } i += 1; } } finally { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } } catch (Exception e) { logger.error(e); JOptionPane.showMessageDialog(null, e, "Error opening file", JOptionPane.ERROR_MESSAGE); } finally { if (br != null) { try { br.close(); } catch (IOException e) { logger.error(e); } } } } }
From source file:UserInterface.FinanceRole.DonateToPoorPeopleJPanel.java
private void donateJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_donateJButtonActionPerformed //Validation//from w ww. j a v a2 s . c om boolean validationSuccess; validationSuccess = validation(); if (validationSuccess) { Person objPPPerson = null; UserAccount objPPUserAccount = null; int selectedPP = poorPeopleJTable.getSelectedRow(); if (selectedPP < 0) { JOptionPane.showMessageDialog(null, "Please select a Person"); return; } objPPUserAccount = (UserAccount) poorPeopleJTable.getValueAt(selectedPP, 2); if (objPPUserAccount != null) { objPPPerson = objPPUserAccount.getObjPerson(); objWorldEnterprise.getObjTransactionDirectory().updateTransactionAccount(); BigDecimal worldBalance = objWorldEnterprise.getObjTransactionDirectory().getAvailableRealBalance(); int positiveWorldBalance = worldBalance.compareTo(donationAmount); if (positiveWorldBalance >= 1) { int response = JOptionPane.showConfirmDialog(null, "Total donation of $ " + donationAmount + "/- Do you want to Donate?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { //PoorPeople Transaction Transaction objVirtualPPTransaction = (Transaction) objPPPerson .getObjPoorPeopleTransactionDirectory().addNewTransaction(); objVirtualPPTransaction .setTransactionBDAmount(new BigDecimal(donationAmountJTextField.getText())); objVirtualPPTransaction.setObjUserAccountSource(objUserAccount); objVirtualPPTransaction.setObjUserAccountDestination(objPPUserAccount); objVirtualPPTransaction.setTransactionSource( Transaction.TransactionSourceType.FromWorldEnterprise.getValue()); objVirtualPPTransaction.setTransactionDestination( Transaction.TransactionSourceType.ToPoorPeople.getValue()); objVirtualPPTransaction.setTransactionType(Transaction.TransactionType.Credit.getValue()); objVirtualPPTransaction .setTransactionMode(Transaction.TransactionModeType.Virtual.getValue()); objPPPerson.getObjPoorPeopleTransactionDirectory().updateTransactionAccount(); //WorldEnterprise Transaction Transaction objVirtualWETransaction = (Transaction) objWorldEnterprise .getObjTransactionDirectory().addNewTransaction(); objVirtualWETransaction .setTransactionBDAmount(new BigDecimal(donationAmountJTextField.getText())); objVirtualWETransaction.setObjUserAccountSource(objUserAccount); objVirtualWETransaction.setObjUserAccountDestination(objPPUserAccount); objVirtualWETransaction.setTransactionSource( Transaction.TransactionSourceType.FromWorldEnterprise.getValue()); objVirtualWETransaction.setTransactionDestination( Transaction.TransactionSourceType.ToPoorPeople.getValue()); objVirtualWETransaction.setTransactionType(Transaction.TransactionType.Debit.getValue()); objVirtualWETransaction .setTransactionMode(Transaction.TransactionModeType.Virtual.getValue()); objWorldEnterprise.getObjTransactionDirectory().updateTransactionAccount(); JOptionPane.showMessageDialog(null, "$ " + donationAmount + "/- donated successfully"); //DonationGivenRecords String donationLogs = objVirtualWETransaction.getTransactionID() + "," + objVirtualWETransaction.getTransactionBDAmount() + "," + objVirtualWETransaction.getObjUserAccountSource() + "," + objVirtualWETransaction.getTransactionSource() + "," + objVirtualWETransaction.getObjUserAccountDestination() + "," + objVirtualWETransaction.getTransactionDestination() + "," + objVirtualWETransaction.getTransactionType() + "," + objVirtualWETransaction.getTransactionMode(); GenerateReports.donationGivenRecords(donationLogs); donationAmountJTextField.setText(null); populateTransactionTable(objPPPerson); } } else { JOptionPane.showMessageDialog(null, "World Balance is low"); } } else { JOptionPane.showMessageDialog(null, "Please select again"); } } }
From source file:gdt.jgui.entity.index.JIndexPanel.java
/** * Get the context menu./* w w w .jav a2 s . c om*/ * @return the context menu. */ @Override public JMenu getContextMenu() { menu = new JMenu("Context"); menu.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { //System.out.println("IndexPanel:getConextMenu:menu selected"); menu.removeAll(); JMenuItem expandItem = new JMenuItem("Expand"); expandItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { expandAll(tree, new TreePath(rootNode), true); } }); menu.add(expandItem); JMenuItem collapseItem = new JMenuItem("Collapse"); collapseItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { expandAll(tree, new TreePath(rootNode), false); } }); menu.add(collapseItem); final TreePath[] tpa = tree.getSelectionPaths(); if (tpa != null && tpa.length > 0) { menu.addSeparator(); JMenuItem copyItem = new JMenuItem("Copy"); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cut = false; console.clipboard.clear(); DefaultMutableTreeNode node; String locator$; for (TreePath tp : tpa) { node = (DefaultMutableTreeNode) tp.getLastPathComponent(); locator$ = (String) node.getUserObject(); if (locator$ != null) console.clipboard.putString(locator$); } } }); menu.add(copyItem); JMenuItem cutItem = new JMenuItem("Cut"); cutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cut = true; console.clipboard.clear(); DefaultMutableTreeNode node; String locator$; for (TreePath tp : tpa) { node = (DefaultMutableTreeNode) tp.getLastPathComponent(); locator$ = (String) node.getUserObject(); if (locator$ != null) console.clipboard.putString(locator$); } } }); menu.add(cutItem); JMenuItem deleteItem = new JMenuItem("Delete"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { try { DefaultMutableTreeNode node; String locator$; String nodeKey$; for (TreePath tp : tpa) { node = (DefaultMutableTreeNode) tp.getLastPathComponent(); locator$ = (String) node.getUserObject(); nodeKey$ = Locator.getProperty(locator$, NODE_KEY); index.removeElementItem("index.title", nodeKey$); index.removeElementItem("index.jlocator", nodeKey$); } Entigrator entigrator = console.getEntigrator(entihome$); entigrator.save(index); JConsoleHandler.execute(console, getLocator()); } catch (Exception ee) { LOGGER.info(ee.toString()); } } } }); menu.add(deleteItem); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); return menu; }
From source file:com.tiempometa.muestradatos.JMuestraDatos.java
private void clearTagsMenuItemActionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(this, "Seguro que desea borrar todos los tags? Esta operacin no se puede deshacer", "Borrar tags", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.YES_OPTION) { try {/*from www . j av a2 s.c o m*/ rfidDao.deleteAll(); JOptionPane.showMessageDialog(this, "Se borraron todos los tags", "Despejar Tags", JOptionPane.PLAIN_MESSAGE); } catch (SQLException e1) { JOptionPane.showMessageDialog(this, "Error despejando tags " + e1.getMessage(), "Despejar Tags", JOptionPane.ERROR_MESSAGE); } } }
From source file:com.sshtools.sshvnc.SshVncSessionPanel.java
/** * * * @return/* w w w . j a va 2 s. co m*/ */ public boolean canClose() { if (isConnected()) { if (JOptionPane.showConfirmDialog(this, "Close the current session and exit?", "Exit Application", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) { return false; } } return true; }
From source file:com.sshtools.sshterm.SshTermSessionPanel.java
/** * * * @param event//from www. j a v a 2s . c o m */ public void actionPerformed(ActionEvent event) { // Get the name of the action command String command = event.getActionCommand(); if ((stopAction != null) && command.equals(stopAction.getActionCommand())) { stopRecording(); } if ((recordAction != null) && command.equals(recordAction.getActionCommand())) { // We need to go back to windowed mode if in full screen mode setFullScreenMode(false); // Select the file to record to JFileChooser fileDialog = new JFileChooser(System.getProperty("user.home")); int ret = fileDialog.showSaveDialog(this); if (ret == fileDialog.APPROVE_OPTION) { recordingFile = fileDialog.getSelectedFile(); if (recordingFile.exists() && (JOptionPane.showConfirmDialog(this, "File exists. Are you sure?", "File exists", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION)) { return; } try { recordingOutputStream = new FileOutputStream(recordingFile); statusBar.setStatusText("Recording to " + recordingFile.getName()); setAvailableActions(); } catch (IOException ioe) { showExceptionMessage("Error", "Could not open file for recording\n\n" + ioe.getMessage()); } } } if ((playAction != null) && command.equals(playAction.getActionCommand())) { // We need to go back to windowed mode if in full screen mode setFullScreenMode(false); // Select the file to record to JFileChooser fileDialog = new JFileChooser(System.getProperty("user.home")); int ret = fileDialog.showOpenDialog(this); if (ret == fileDialog.APPROVE_OPTION) { File playingFile = fileDialog.getSelectedFile(); InputStream in = null; try { statusBar.setStatusText("Playing from " + playingFile.getName()); in = new FileInputStream(playingFile); byte[] b = null; int a = 0; while (true) { a = in.available(); if (a == -1) { break; } if (a == 0) { a = 1; } b = new byte[a]; a = in.read(b); if (a == -1) { break; } //emulation.write(b); emulation.getOutputStream().write(b); } statusBar.setStatusText("Finished playing " + playingFile.getName()); setAvailableActions(); } catch (IOException ioe) { statusBar.setStatusText("Error playing " + playingFile.getName()); showExceptionMessage("Error", "Could not open file for playback\n\n" + ioe.getMessage()); } finally { if (in != null) { try { in.close(); } catch (IOException ioe) { log.error(ioe); } } } } } if ((closeAction != null) && command.equals(closeAction.getActionCommand())) { closeSession(); } }
From source file:livecanvas.mesheditor.MeshEditor.java
private void save(File file) { if (!canSave()) { return;/*from w w w. j ava 2s .c o m*/ } if (file == null) { FileDialog fd = new FileDialog(JOptionPane.getFrameForComponent(MeshEditor.this), "Save"); fd.setVisible(true); String file_str = fd.getFile(); if (file_str == null) { return; } file = new File(fd.getDirectory() + "/" + file_str); } try { Layer rootLayer = layersView.getRootLayer(); for (Layer l : rootLayer.getSubLayersRecursively()) { Path path = l.getPath(); if (path.isFinalized()) { Mesh mesh = path.getMesh(); if (mesh.getControlPointsCount() < 2) { String msg = "At least one mesh has less than 2 control points.\n" + "You may not be able to use it for animation. Do you\n" + "still want to continue?"; if (JOptionPane.showConfirmDialog(this, msg, "Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) { return; } else { break; } } } } PrintWriter out = new PrintWriter(new FileOutputStream(file)); JSONObject doc = new JSONObject(); doc.put("rootLayer", rootLayer.toJSON()); doc.put("canvas", canvas.toJSON()); doc.write(out); out.close(); } catch (Exception e1) { e1.printStackTrace(); String msg = "An error occurred while trying to load."; JOptionPane.showMessageDialog(JOptionPane.getFrameForComponent(MeshEditor.this), msg, "Error", JOptionPane.ERROR_MESSAGE); } repaint(); }
From source file:com.tiempometa.muestradatos.JProgramTags.java
@Override public void handleReadings(List<TagReading> readings) { bibLabel.setText(""); if (readings.size() > 0) { if (readings.size() == 1) { statusLabel.setBackground(Color.cyan); statusLabel.setText("Leyendo tag"); for (TagReading tagReading : readings) { logger.info("Tag data dump"); logger.info(tagReading.getTagReadData().getTag().epcString()); logger.info(String.valueOf(tagReading.getTagReadData().getData().length)); logger.info(Hex.encodeHexString(tagReading.getTagReadData().getData())); logger.info(String.valueOf(tagReading.getTagReadData().getEPCMemData().length)); logger.info(Hex.encodeHexString(tagReading.getTagReadData().getEPCMemData())); logger.info(String.valueOf(tagReading.getTagReadData().getTIDMemData().length)); logger.info(Hex.encodeHexString(tagReading.getTagReadData().getTIDMemData())); logger.info(String.valueOf(tagReading.getTagReadData().getReservedMemData().length)); logger.info(Hex.encodeHexString(tagReading.getTagReadData().getReservedMemData())); logger.info(String.valueOf(tagReading.getTagReadData().getUserMemData().length)); logger.info(Hex.encodeHexString(tagReading.getTagReadData().getUserMemData())); if (tagReading.getTid() == null) { try { tagReading.setTid(ReaderContext.readTid(tagReading.getEpc(), 12)); if (logger.isDebugEnabled()) { logger.debug("Got tag " + tagReading.getEpc() + " - " + tagReading.getTid()); }// w ww . j a v a2s. c o m // try { statusLabel.setBackground(Color.green); statusLabel.setText("Tag leido"); tidTextField.setText(tagReading.getTid().toLowerCase()); epcTextField.setText(tagReading.getEpc().toLowerCase()); programmedEpcTextField.setText(""); // find tag by EPC/TID in database logger.debug("Looking up rfid by epc " + tagReading.getEpc() + " epc char " + Hex.encodeHexString(tagReading.getEpc().getBytes())); Rfid rfid = totalRfidMap.get(tagReading.getEpc().toUpperCase()); if (rfid == null) { logger.debug("Rfid string not in database tag list. Programming tag."); // if in DB, warn // if not then program with next chipnumber programTag(tagReading); } else { logger.debug("Rfid string IN database tag list."); Rfid batchRfid = rfidMap.get(tagReading.getEpc()); if (batchRfid == null) { logger.debug("Rfid string IN current program batch"); int response = JOptionPane.showConfirmDialog(this, "Este tag tiene un cdigo que existe en el evento actual.\n" + "Corresponde al nmero " + rfid.getBib() + "\nDesea sobreescribir este tag?", "Tag ya programado", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.YES_OPTION) { programTag(tagReading); } } else { JOptionPane.showMessageDialog(this, "Este tag tiene un cdigo que ya ha sido programado en este lote.", "Tag ya programado", JOptionPane.ERROR_MESSAGE); } } try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } statusLabel.setBackground(Color.white); statusLabel.setText("Remover tag"); try { Thread.sleep(500); } catch (InterruptedException e1) { e1.printStackTrace(); } } catch (ReaderException e) { // TODO Auto-generated catch block e.printStackTrace(); statusLabel.setBackground(Color.red); statusLabel.setText("Error"); try { Thread.sleep(500); } catch (InterruptedException e1) { e1.printStackTrace(); } } } } } else { statusLabel.setBackground(Color.orange); statusLabel.setText("Dos o ms tags"); } } else { statusLabel.setBackground(Color.yellow); statusLabel.setText("Sin tag"); } }
From source file:org.gumtree.vis.plot1d.Plot1DPanel.java
private void showPropertyEditor(int tabIndex) { XYDataset dataset = getChart().getXYPlot().getDataset(); if (selectedSeriesIndex >= 0 && selectedSeriesIndex < dataset.getSeriesCount()) { Plot1DChartEditor.setSuggestedSeriesKey((String) dataset.getSeriesKey(selectedSeriesIndex)); }//from w w w . j a v a2 s . com Plot1DChartEditor editor = new Plot1DChartEditor(getChart(), this); editor.getTabs().setSelectedIndex(tabIndex); int result = JOptionPane.showConfirmDialog(this, editor, localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { editor.updateChart(getChart()); } }
From source file:be.nbb.demetra.dfm.output.simulation.RMSEGraphView.java
private void filterButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filterButtonActionPerformed int r = JOptionPane.showConfirmDialog(chartPanel, filterPanel, "Select evaluation sample", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (r == JOptionPane.OK_OPTION) { updateChart();//from w w w.j a v a 2 s .c o m } }