List of usage examples for javax.swing JOptionPane YES_OPTION
int YES_OPTION
To view the source code for javax.swing JOptionPane YES_OPTION.
Click Source Link
From source file:de.quadrillenschule.azocamsyncd.astromode.gui.AstroModeJPanel.java
private void removeallJobsjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeallJobsjButtonActionPerformed if (JOptionPane.showConfirmDialog(parentFrame, "Really remove all jobs?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { for (PhotoSerie ps : jobList) { try { SmartPhoneWrapper.remove(ps); } catch (IOException ex) { Logger.getLogger(AstroModeJPanel.class.getName()).log(Level.SEVERE, null, ex); }/*from www .j ava 2 s . c om*/ } } }
From source file:org.fhaes.fhsamplesize.view.FHSampleSize.java
/** * Open a JFileChooser and return the file that the user specified for saving. Takes a parameter that specifies the type of file. Either * TAB or PNG./*from w w w . j av a 2 s .c o m*/ * * @return */ private File getFileFromSaveDialog(String fileTypeToSave) { String lastVisitedFolder = App.prefs.getPref(PrefKey.PREF_LAST_EXPORT_FOLDER, null); JFileChooser fc = new JFileChooser(lastVisitedFolder); File outputFile; if (fileTypeToSave == "TAB") { TABFilter filterTAB = new TABFilter(); fc.addChoosableFileFilter(filterTAB); fc.setFileFilter(filterTAB); fc.setDialogTitle("Export table as text file..."); } else if (fileTypeToSave == "PDF") { PDFFilter filterPDF = new PDFFilter(); fc.addChoosableFileFilter(filterPDF); fc.setFileFilter(filterPDF); fc.setDialogTitle("Export chart as PDF..."); } fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setMultiSelectionEnabled(false); int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { outputFile = fc.getSelectedFile(); if (FileUtils.getExtension(outputFile.getAbsolutePath()) == "") { log.debug("Output file extension not set by user"); if (fc.getFileFilter().getDescription().equals(new CSVFileFilter().getDescription())) { log.debug("Adding csv extension to output file name"); outputFile = new File(outputFile.getAbsolutePath() + ".csv"); } else if (fc.getFileFilter().getDescription().equals(new PDFFilter().getDescription())) { log.debug("Adding pdf extension to output file name"); outputFile = new File(outputFile.getAbsolutePath() + ".pdf"); } } else { log.debug("Output file extension set my user to '" + FileUtils.getExtension(outputFile.getAbsolutePath()) + "'"); } App.prefs.setPref(PrefKey.PREF_LAST_EXPORT_FOLDER, outputFile.getAbsolutePath()); } else { return null; } if (outputFile.exists()) { Object[] options = { "Overwrite", "No", "Cancel" }; // notes about parameters: null (don't use custom icon), options (the titles of buttons), options[0] (default button title) int response = JOptionPane.showOptionDialog(App.mainFrame, "The file '" + outputFile.getName() + "' already exists. Are you sure you want to overwrite?", "Confirm", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (response != JOptionPane.YES_OPTION) return null; } return outputFile; }
From source file:com.biosis.biosislite.vistas.inventario.MantenimientoBien.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = AbstractControlador.ELIMINAR; if (tblbienes.getSelectedRow() != -1) { Integer codigo = tblbienes.getSelectedRow(); Bien bien = bienControlador.buscarPorId(lista.get(codigo).getId()); if (bien != null) { if (JOptionPane.showConfirmDialog(null, "Desea Eliminar la Bien?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { int[] filas = tblbienes.getSelectedRows(); for (int i = 0; i < filas.length; i++) { Bien bien2 = lista.get(filas[0]); lista.remove(bien2); bienControlador.setSeleccionado(bien2); bienControlador.accion(accion); }// w w w .j a v a 2 s . c o m if (bienControlador.accion(accion) == 3) { JOptionPane.showMessageDialog(null, "Bien eliminada correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Bien no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Bien no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(null, "Debe seleccionar un Bien", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } }
From source file:uk.ac.lkl.cram.ui.ModuleFrame.java
private void removeSelectedLineItem() { LineItem selectedLineItem = sharedSelectionModel.getSelectedLineItem(); if (selectedLineItem != null) { int reply = JOptionPane.showConfirmDialog(this, "Are you sure you want to remove \'" + selectedLineItem.getName() + "\'?", "Remove TLA", JOptionPane.YES_NO_OPTION); if (reply == JOptionPane.YES_OPTION) { int i = selectedLineItem.removeFrom(module); UndoableEdit edit = new RemoveLineItemEdit(module, selectedLineItem, i); undoHandler.addEdit(edit);//from w w w .j a v a2 s . c om } else { LOGGER.info("Remove cancelled"); } } else { LOGGER.warning("Unable to remove this line item"); } }
From source file:de.mendelson.comm.as2.client.AS2Gui.java
/**Starts a dialog that allows to send files manual to a partner */// w ww . j a va 2 s . c o m private void sendFileManualFromSelectedTransaction() { if (this.configConnection == null) { return; } int requestValue = JOptionPane.showConfirmDialog(this, this.rb.getResourceString("dialog.resend.message"), this.rb.getResourceString("dialog.resend.title"), JOptionPane.YES_NO_OPTION); if (requestValue != JOptionPane.YES_OPTION) { return; } final String uniqueId = this.getClass().getName() + ".sendFileManualFromSelectedTransaction." + System.currentTimeMillis(); Runnable runnable = new Runnable() { @Override public void run() { File tempFile = null; try { AS2Gui.this.as2StatusBar.startProgressIndeterminate( AS2Gui.this.rb.getResourceString("menu.file.resend"), uniqueId); int selectedRow = AS2Gui.this.jTableMessageOverview.getSelectedRow(); if (selectedRow >= 0) { //download the payload for the selected message MessageAccessDB messageAccess = new MessageAccessDB(AS2Gui.this.configConnection, AS2Gui.this.runtimeConnection); JDialogManualSend dialog = new JDialogManualSend(AS2Gui.this, AS2Gui.this.configConnection, AS2Gui.this.runtimeConnection, AS2Gui.this.getBaseClient(), AS2Gui.this.as2StatusBar, AS2Gui.this.rb.getResourceString("uploading.to.server")); AS2Message message = ((TableModelMessageOverview) AS2Gui.this.jTableMessageOverview .getModel()).getRow(selectedRow); if (message != null) { AS2MessageInfo info = (AS2MessageInfo) message.getAS2Info(); PartnerAccessDB partnerAccess = new PartnerAccessDB(AS2Gui.this.configConnection, AS2Gui.this.runtimeConnection); Partner sender = partnerAccess.getPartner(info.getSenderId()); Partner receiver = partnerAccess.getPartner(info.getReceiverId()); List<AS2Payload> payloads = messageAccess.getPayload(info.getMessageId()); for (AS2Payload payload : payloads) { message.addPayload(payload); } if (message.getPayloadCount() > 0) { AS2Payload payload = message.getPayload(0); //request the payload file from the server TransferClientWithProgress transferClient = new TransferClientWithProgress( AS2Gui.this.getBaseClient(), AS2Gui.this.as2StatusBar.getProgressPanel()); DownloadRequestFile request = new DownloadRequestFile(); request.setFilename(payload.getPayloadFilename()); InputStream inStream = null; OutputStream outStream = null; try { DownloadResponseFile response = (DownloadResponseFile) transferClient .download(request); if (response.getException() != null) { throw response.getException(); } String tempFilename = "as2.bin"; if (payload.getOriginalFilename() != null) { tempFilename = payload.getOriginalFilename(); } tempFile = AS2Tools.createTempFile(tempFilename, ""); outStream = new FileOutputStream(tempFile); inStream = response.getDataStream(); AS2Gui.this.copyStreams(inStream, outStream); outStream.flush(); } catch (Throwable e) { AS2Gui.this.logger.severe(e.getMessage()); return; } finally { if (inStream != null) { try { inStream.close(); } catch (Exception e) { } } if (outStream != null) { try { outStream.close(); } catch (Exception e) { } } } dialog.initialize(sender, receiver, tempFile.getAbsolutePath()); } dialog.performSend(); info.setResendCounter(info.getResendCounter() + 1); messageAccess.updateResendCounter(info); Logger.getLogger(AS2Server.SERVER_LOGGER_NAME).log(Level.INFO, AS2Gui.this.rb.getResourceString("resend.performed"), info); } AS2Gui.this.as2StatusBar.stopProgressIfExists(uniqueId); } } catch (Throwable e) { //nop } finally { AS2Gui.this.as2StatusBar.stopProgressIfExists(uniqueId); if (tempFile != null) { tempFile.delete(); } } } }; Executors.newSingleThreadExecutor().submit(runnable); }
From source file:contactsdirectory.frontend.MainJFrame.java
private void removeContact() { if (jListContact.getSelectedIndex() < 0) { JOptionPane.showMessageDialog(rootPane, localizedTexts.getString("noContactSelected"), "", JOptionPane.INFORMATION_MESSAGE); return;//from ww w . j a v a 2s. co m } if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(rootPane, localizedTexts.getString("deleteContactMsg"), "", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)) { try { Contact contact = (Contact) jListContact.getSelectedValue(); jProgressBar.setIndeterminate(true); jProgressBar.setVisible(true); RemoveContactSwingWorker worker = new RemoveContactSwingWorker(contact); worker.execute(); ((DefaultListModel<Contact>) jListContact.getModel()).removeElement(contact); jProgressBar.setVisible(false); jProgressBar.setIndeterminate(false); } catch (RuntimeException e) { JOptionPane.showMessageDialog(this, localizedTexts.getString("removeContactErrMsg"), localizedTexts.getString("errorMsgTitle"), JOptionPane.ERROR_MESSAGE); } } }
From source file:ded.ui.DiagramController.java
/** Try to load a diagram by reading the JSON out of the comment * section of the PNG file 'pngName'. If that succeeds, return * non-null, and also set:/*from w ww . j a v a 2 s . c o m*/ * * * this.importedFile * * this.dirty * * this.fileName * * Return null if this failed but we already explained the problem * to the user, or the user cancels; or throw an exception otherwise. */ private Diagram loadFromPNG(String pngName) throws Exception { // Get the name of the image source file. String sourceFileName = pngName.substring(0, pngName.length() - 4); File sourceFile = new File(sourceFileName); if (sourceFile.exists()) { if (SwingUtil.confirmationBox(this, "You are trying to open a diagram PNG file \"" + pngName + "\", but the source DED file \"" + sourceFileName + "\" is right next to it. Usually, you should open " + "the source file instead. Otherwise, that source file " + "will be overwritten when you next save. Are you sure you want to " + "read the diagram out of the PNG comment?", "Are you sure?", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) { return null; } } // Try to read the comment from the file. If the file is corrupt // or cannot be read, this will throw. But if the comment is merely // absent, then this will return null. String comment = ImageFileUtil.getPNGComment(new File(pngName)); if (comment == null || comment.isEmpty()) { SwingUtil.errorMessageBox(this, "The PNG file \"" + pngName + "\" does not contain a comment, " + "so it is not possible to read the diagram source from it."); return null; } // Do a preliminary sanity check on the comment. if (!comment.startsWith("{")) { SwingUtil.errorMessageBox(this, "The PNG file \"" + pngName + "\" contains a comment, " + "but it does not begin with '{', so it is not a comment " + "created by DED, " + "so it is not possible to read the diagram source from it."); return null; } // Try parsing the comment as diagram JSON. Diagram d; try { d = Diagram.readFromReader(new StringReader(comment)); } catch (Exception e) { this.exnErrorMessageBox("The PNG file \"" + pngName + "\" has a comment that might " + "have been created by DED, but parsing that comment as " + "a diagram source file failed", e); return null; } // That worked. Update the editor state variables. this.importedFile = false; // Note: We chop off ".png" and treat that as the name for // subsequent saves. this.setFileName(sourceFileName); // The file is not considered dirty because they are no // unsaved changes, even though the next save may cause // on-disk changes due to overwriting a source file if the // user ignored the warning above. this.dirty = false; return d; }
From source file:org.gumtree.vis.awt.JChartPanel.java
@Override public void doSaveAs() throws IOException { JFileChooser fileChooser = new JFileChooser(); String currentDirectory = System.getProperty(StaticValues.SYSTEM_SAVE_PATH_LABEL); if (currentDirectory != null) { File savePath = new File(currentDirectory); if (savePath.exists() && savePath.isDirectory()) { fileChooser.setCurrentDirectory(savePath); }//w ww .j av a2 s. co m } ExtensionFileFilter ascFilter = new ExtensionFileFilter("Text_Files", ".txt"); ExtensionFileFilter jpgFilter = new ExtensionFileFilter("JPG_Image_Files", ".jpg"); ExtensionFileFilter pngFilter = new ExtensionFileFilter("PNG_Image_Files", ".png"); fileChooser.addChoosableFileFilter(pngFilter); fileChooser.addChoosableFileFilter(jpgFilter); fileChooser.addChoosableFileFilter(ascFilter); fileChooser.setFileFilter(jpgFilter); int option = fileChooser.showSaveDialog(this); if (option == JFileChooser.APPROVE_OPTION) { String filename = fileChooser.getSelectedFile().getPath(); String selectedDescription = fileChooser.getFileFilter().getDescription(); String fileExtension = StaticValues.DEFAULT_IMAGE_FILE_EXTENSION; if (selectedDescription.toLowerCase().contains("png")) { fileExtension = "png"; if (!filename.toLowerCase().endsWith(".png")) { filename = filename + ".png"; } } else if (selectedDescription.toLowerCase().contains("jpg")) { fileExtension = "jpg"; if (!filename.toLowerCase().endsWith(".jpg")) { filename = filename + ".jpg"; } } else if (selectedDescription.toLowerCase().contains("text")) { fileExtension = "txt"; if (!filename.toLowerCase().endsWith(".txt")) { filename = filename + ".txt"; } } File selectedFile = new File(filename); int confirm = JOptionPane.YES_OPTION; if (selectedFile.exists()) { confirm = JOptionPane.showConfirmDialog(this, selectedFile.getName() + " exists, overwrite?", "Confirm Overwriting", JOptionPane.YES_NO_OPTION); } if (confirm == JOptionPane.YES_OPTION) { saveTo(filename, fileExtension); System.setProperty(StaticValues.SYSTEM_SAVE_PATH_LABEL, fileChooser.getSelectedFile().getParent()); } } }
From source file:condorclient.MainFXMLController.java
@FXML public void removedWithoutClosingPoolFired(ActionEvent event) {//?close pool int delNo = 0; int delsum = 0; int n = JOptionPane.showConfirmDialog(null, "??", "", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { //checkboxclusterId System.out.print(Thread.currentThread().getName() + "\n"); URL url = null;/*from w ww .ja v a 2s.c o m*/ XMLHandler handler = new XMLHandler(); String scheddStr = handler.getURL("schedd"); try { url = new URL(scheddStr); //url = new URL("http://localhost:9628"); } catch (MalformedURLException e3) { // TODO Auto-generated catch block e3.printStackTrace(); } Schedd schedd = null; try { schedd = new Schedd(url); } catch (ServiceException ex) { Logger.getLogger(CondorClient.class.getName()).log(Level.SEVERE, null, ex); } //ClassAdStructAttr[] ClassAd ad = null;//birdbath.ClassAd; ClassAdStructAttr[][] classAdArray = null; int cluster = 0; int job = 0; Transaction xact = schedd.createTransaction(); try { xact.begin(30); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // System.out.println("delClusterIds:" + delClusterIds.toString()); //s int removeId = 0; final List<?> selectedNodeList = new ArrayList<>(table.getSelectionModel().getSelectedItems()); for (Object o : selectedNodeList) { if (o instanceof ObservableDisplayedClassAd) { removeId = Integer.parseInt(((ObservableDisplayedClassAd) o).getClusterId()); } } //e String findreq = "owner==\"" + condoruser + "\"&&ClusterId==" + removeId; try { classAdArray = schedd.getJobAds(findreq); } catch (RemoteException ex) { Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex); } for (ClassAdStructAttr[] x : classAdArray) { ad = new ClassAd(x); job = Integer.parseInt(ad.get("ProcId")); try { xact.removeJob(removeId, job, ""); // System.out.print("ts.getClusterId():" + showClusterId + "\n"); } catch (RemoteException ex) { Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex); } } try { xact.commit(); } catch (RemoteException e) { e.printStackTrace(); } } else if (n == JOptionPane.NO_OPTION) { System.out.println("qu xiao"); } }
From source file:com.biosis.biosislite.vistas.inventario.MantenimientoBien.java
private void btnguardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnguardarActionPerformed // TODO add your handling code here: String palabra = ""; String palabra2 = ""; if (accion == 1) { palabra = "registrar"; palabra2 = "registrado"; if (this.validar && (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Bien?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)) { bienControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase()); // bienControlador.getSeleccionado().setCodigo(idField.getText()); bienControlador.getSeleccionado().setDescripcion(descripcionField.getText().toUpperCase()); bienControlador.getSeleccionado().setFoto(fotoField.getText()); bienControlador.getSeleccionado().setStockMinimo((Integer) spnStock.getValue()); bienControlador.getSeleccionado().setStockMaximo((Integer) spnStockMax.getValue()); if (this.validar) { bienControlador.getSeleccionado().setCodigo(this.txtCodigo.getText()); this.validar = false; }/*from w ww . j a v a2 s . co m*/ // Clase clase = (Clase) cmbClase.getSelectedItem(); // bienControlador.getSeleccionado().setClase(clase); bienControlador.accion(accion); lista.add(bienControlador.getSeleccionado()); if (accion == 1) { JOptionPane.showMessageDialog(null, "Bien " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Bien no " + palabra2, "Mensaje del Sistema", JOptionPane.WARNING_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Error en la informacin ingresada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else if (accion == 2) { palabra = "modificar"; palabra2 = "modificado"; if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Bien?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { if (accion == 2) { JOptionPane.showMessageDialog(null, "Bien " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); lista.clear(); bienControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase()); // bienControlador.getSeleccionado().setCodigo(nombreField.getText()); bienControlador.getSeleccionado().setDescripcion(descripcionField.getText().toUpperCase()); bienControlador.getSeleccionado().setFoto(fotoField.getText()); bienControlador.getSeleccionado().setStockMinimo((Integer) spnStock.getValue()); bienControlador.getSeleccionado().setStockMaximo((Integer) spnStockMax.getValue()); // Clase clase = (Clase) cmbClase.getSelectedItem(); // bienControlador.getSeleccionado().setClase(clase); bienControlador.accion(accion); listar(); } else { JOptionPane.showMessageDialog(null, "Bien no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Bien no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } for (DetalleBienCampo detalle : lista3) { detalle.setBien(bienControlador.getSeleccionado()); detalleControlador.setSeleccionado(detalle); detalleControlador.accion(AbstractControlador.MODIFICAR); } lista3.clear(); FormularioUtil.activarComponente(panelOpciones, true); FormularioUtil.activarComponente(panelGuardar, false); FormularioUtil.activarComponente(panelDatos, false); FormularioUtil.limpiarComponente(panelDatos); fotoLbl.setIcon(null); descripcionField.setText(null); }