List of usage examples for javax.swing JOptionPane YES_NO_OPTION
int YES_NO_OPTION
To view the source code for javax.swing JOptionPane YES_NO_OPTION.
Click Source Link
showConfirmDialog
. From source file:UserInterface.FinanceRole.DonateToPoorPeopleJPanel.java
private void donateJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_donateJButtonActionPerformed //Validation//from w ww . ja v a 2 s .co m 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: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 w w w.j a va2s. 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.proyecto.vista.MantenimientoPeriodo.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = Controlador.ELIMINAR;//from ww w. j av a 2 s.c o m if (tblperiodo.getSelectedRow() != -1) { Integer codigo = tblperiodo.getSelectedRow(); Periodo periodo = periodoControlador.buscarPorId(lista.get(codigo).getId()); if (periodo != null) { if (JOptionPane.showConfirmDialog(null, "Desea Eliminar el Periodo?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { int[] filas = tblperiodo.getSelectedRows(); for (int i = 0; i < filas.length; i++) { Periodo periodo2 = lista.get(filas[0]); lista.remove(periodo2); periodoControlador.setSeleccionado(periodo2); periodoControlador.accion(accion); } if (periodoControlador.accion(accion) == 3) { JOptionPane.showMessageDialog(null, "Periodo eliminado correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Periodo no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Periodo no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(null, "Debe seleccionar un Periodo", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } }
From source file:edu.mbl.jif.imaging.mmtiff.MultipageTiffReader.java
/** * This code is intended for use in the scenario in which a datset terminates before properly * closing, thereby preventing the multipage tiff writer from putting in the index map, * comments, channels, and OME XML in the ImageDescription tag location *///from w w w. ja va 2 s. c om private void fixIndexMap(long firstIFD) throws IOException, JSONException { int choice = JOptionPane.showConfirmDialog(null, "This dataset cannot be opened bcause it appears to have \n" + "been improperly saved. Would you like Micro-Manger to attempt to fix it?", "Micro-Manager", JOptionPane.YES_NO_OPTION); if (choice == JOptionPane.NO_OPTION) { return; } long filePosition = firstIFD; indexMap_ = new HashMap<String, Long>(); // final ProgressBar progressBar = new ProgressBar("Fixing dataset", 0, (int) (fileChannel_.size() / 2L)); // progressBar.setRange(0, (int) (fileChannel_.size() / 2L)); // progressBar.setProgress(0); // progressBar.setVisible(true); long nextIFDOffsetLocation = 0; IFDData data = null; while (filePosition > 0) { try { data = readIFD(filePosition); TaggedImage ti = readTaggedImage(data); if (ti.tags == null) { //Blank placeholder image, dont add to index map filePosition = data.nextIFD; nextIFDOffsetLocation = data.nextIFDOffsetLocation; continue; } String label = null; label = MDUtils.getLabel(ti.tags); if (label == null) { break; } indexMap_.put(label, filePosition); final int progress = (int) (filePosition / 2L); // SwingUtilities.invokeLater(new Runnable() { // public void run() { // progressBar.setProgress(progress); // } // }); filePosition = data.nextIFD; nextIFDOffsetLocation = data.nextIFDOffsetLocation; } catch (Exception e) { break; } } //progressBar.setVisible(false); filePosition += writeIndexMap(filePosition); ByteBuffer buffer = ByteBuffer.allocate(4); buffer.order(byteOrder_); buffer.putInt(0, 0); fileChannel_.write(buffer, nextIFDOffsetLocation); raFile_.setLength(filePosition + 8); fileChannel_.close(); raFile_.close(); //reopen createFileChannel(); ReportingUtils.showMessage("Dataset succcessfully repaired! Resave file to reagain full funtionality"); }
From source file:com.biosis.biosislite.vistas.inventario.MantenimientoCampo.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = AbstractControlador.ELIMINAR; if (tblclase.getSelectedRow() != -1) { Integer id = tblclase.getSelectedRow(); Campo campo = campoControlador.buscarPorId(lista.get(id).getId()); if (campo != null) { if (JOptionPane.showConfirmDialog(null, "Desea Eliminar el Campo?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { int[] filas = tblclase.getSelectedRows(); for (int i = 0; i < filas.length; i++) { Campo campo2 = lista.get(filas[0]); lista.remove(campo2); campoControlador.setSeleccionado(campo2); campoControlador.accion(accion); }// w w w. j av a 2 s.com if (campoControlador.accion(accion) == 3) { JOptionPane.showMessageDialog(null, "Campo eliminada correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Campo no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Campo no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(null, "Debe seleccionar un Campo de la lista", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } }
From source file:com.sshtools.sshvnc.SshVncSessionPanel.java
/** * * * @return/* ww w .ja v a 2s . 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:net.sf.jabref.external.DroppedFileHandler.java
/** * Move the given file to the base directory for its file type, and rename * it to the given filename./*from ww w . j a v a 2 s .c o m*/ * * @param fileName The name of the source file. * @param destFilename The destination filename. * @param edits TODO we should be able to undo this action * @return true if the operation succeeded. */ private boolean doMove(String fileName, String destFilename, NamedCompound edits) { List<String> dirs = panel.getBibDatabaseContext().getFileDirectory(); int found = -1; for (int i = 0; i < dirs.size(); i++) { if (new File(dirs.get(i)).exists()) { found = i; break; } } if (found < 0) { // OOps, we don't know which directory to put it in, or the given // dir doesn't exist.... // This should not happen!! LOGGER.warn("Cannot determine destination directory or destination directory does not exist"); return false; } File toFile = new File(dirs.get(found) + System.getProperty("file.separator") + destFilename); if (toFile.exists()) { int answer = JOptionPane.showConfirmDialog(frame, Localization.lang("'%0' exists. Overwrite file?", toFile.getAbsolutePath()), Localization.lang("Overwrite file?"), JOptionPane.YES_NO_OPTION); if (answer == JOptionPane.NO_OPTION) { return false; } } File fromFile = new File(fileName); if (fromFile.renameTo(toFile)) { return true; } else { JOptionPane.showMessageDialog(frame, Localization.lang("Could not move file '%0'.", toFile.getAbsolutePath()) + Localization.lang("Please move the file manually and link in place."), Localization.lang("Move file failed"), JOptionPane.ERROR_MESSAGE); return false; } }
From source file:livecanvas.mesheditor.MeshEditor.java
private void save(File file) { if (!canSave()) { return;/*from w w w . j a va2s . c om*/ } 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.sshtools.sshterm.SshTermSessionPanel.java
/** * * * @param event/*from w ww . ja v a 2 s . c om*/ */ 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:de.codesourcery.eve.skills.ui.components.impl.MarketPriceEditorComponent.java
protected boolean checkForOrdersConflictingWithExistingData(MarketLogFile logFile, final PriceInfo.Type priceType) { // get date of latest price currently known MarketFilter filter = new MarketFilterBuilder(priceType, logFile.getRegion()).end(); final List<PriceInfo> history = fetchPriceInfo(filter, logFile.getInventoryType()); if (history.isEmpty() || logFile.isEmpty()) { return true; }/*from w w w. jav a 2 s. com*/ EveDate latestHistoryDate = null; for (PriceInfo info : history) { if (latestHistoryDate == null || info.getTimestamp().compareTo(latestHistoryDate) >= 0) { latestHistoryDate = info.getTimestamp(); } } // get earliest price timestamp from market log final EveDate[] earliestFileDate = new EveDate[1]; logFile.visit(new IMarketLogVisitor() { @Override public void visit(MarketLogEntry entry) { if (!priceType.matches(entry.getType())) { return; } if (earliestFileDate[0] == null || entry.getIssueDate().compareTo(earliestFileDate[0]) < 0) { earliestFileDate[0] = entry.getIssueDate(); } } }); if (earliestFileDate[0] == null) { return true; } // check for overlapping of price data from file // with already known prices if (earliestFileDate[0].compareTo(latestHistoryDate) <= 0) { String typeLabel; switch (priceType) { case BUY: typeLabel = "buy"; break; case SELL: typeLabel = "sell"; break; default: throw new RuntimeException("Unhandled switch/case"); } final String label = "<HTML><BODY>" + "<BR><BR>" + "WARNING: This market logfile contains " + typeLabel + " orders that conflict <BR> with " + "data already present in the application's database.<BR><BR>"; final String[] options = { "Ignore conflicting " + typeLabel + " orders", "Cancel" }; final int userChoice = JOptionPane.showOptionDialog(null, label, "Orders from market log conflict with existing data", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); if (userChoice == 0) { final int size = logFile.size(); final int removedCount = logFile.removeEntriesOlderThan(latestHistoryDate, priceType); JOptionPane.showMessageDialog(null, "Removed " + removedCount + " of " + size + " " + typeLabel + " orders total ( left: " + logFile.size() + " )"); } else { return false; } } return true; }