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:livecanvas.mesheditor.MeshEditor.java
private void exit() { if (JOptionPane.showConfirmDialog(MeshEditor.this, "Are you sure you want to exit?", "Exit", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) { return;// www . jav a2s. c om } System.exit(0); }
From source file:com.floreantpos.main.SetUpWindow.java
private void saveConfigData() { User user = null;/* w w w . j av a 2 s . c o m*/ /*try { user = UserDAO.getInstance().findUser(Integer.valueOf(tfUserId.getText())); } catch (UserNotFoundException ex) { user = new User(); }*/ Terminal terminal = new Terminal(); if (!updateModel(user, terminal)) return; /*UserType administrator = new UserType(); administrator.setName(com.floreantpos.POSConstants.ADMINISTRATOR); administrator.setPermissions(new HashSet<UserPermission>(Arrays.asList(UserPermission.permissions))); UserTypeDAO.getInstance().saveOrUpdate(administrator); user.setType(administrator); UserDAO.getInstance().saveOrUpdate(user);*/ TerminalDAO.getInstance().saveOrUpdate(terminal); POSMessageDialog.showMessage(Messages.getString("SetUpWindow.0")); //$NON-NLS-1$ int i = JOptionPane.showConfirmDialog(this, "Do you want to start application?", "Message", //$NON-NLS-1$//$NON-NLS-2$ JOptionPane.YES_NO_OPTION); if (i != JOptionPane.YES_OPTION) { System.exit(1); } else { try { Main.restart(); } catch (IOException e) { } catch (InterruptedException e) { } catch (URISyntaxException e) { } } }
From source file:lu.fisch.moenagade.model.Project.java
public boolean askToSave(boolean forceSave) { try {//from w w w. j a v a 2s .co m if ((!isEmpty() && isChanged()) || forceSave) { int answ = JOptionPane.showConfirmDialog(frame, "Do you want to save the current project?", "Save project?", JOptionPane.YES_NO_CANCEL_OPTION); if (answ == JOptionPane.YES_OPTION) { if (directoryName == null) return saveWithAskingLocation(); else return save(); } else if (answ == JOptionPane.NO_OPTION) { return !forceSave; } else return false; } return true; } catch (Exception e) { JOptionPane.showMessageDialog(frame, "A terrible error occured!\n" + e.getMessage() + "\n", "Error", JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR); return false; } }
From source file:com.holycityaudio.SpinCAD.SpinCADFile.java
public void fileSaveSpj(SpinCADBank bank) { // Create a file chooser String savedPath = prefs.get("MRUSpjFolder", ""); String[] spnFileNames = new String[8]; final JFileChooser fc = new JFileChooser(savedPath); // In response to a button click: FileNameExtensionFilter filter = new FileNameExtensionFilter("Spin Project Files", "spj"); fc.setFileFilter(filter);// w w w. j a va2 s.c om // XXX debug fc.showSaveDialog(new JFrame()); File fileToBeSaved = fc.getSelectedFile(); if (!fc.getSelectedFile().getAbsolutePath().endsWith(".spj")) { fileToBeSaved = new File(fc.getSelectedFile() + ".spj"); } int n = JOptionPane.YES_OPTION; if (fileToBeSaved.exists()) { JFrame frame1 = new JFrame(); n = JOptionPane.showConfirmDialog(frame1, "Would you like to overwrite it?", "File already exists!", JOptionPane.YES_NO_OPTION); } if (n == JOptionPane.YES_OPTION) { // filePath points at the desired Spj file String filePath = fileToBeSaved.getPath(); String folder = fileToBeSaved.getParent().toString(); // export the individual SPN files for (int i = 0; i < 8; i++) { try { String asmFileNameRoot = FilenameUtils.removeExtension(bank.patch[i].patchFileName); String asmFileName = folder + "\\" + asmFileNameRoot + ".spn"; if (bank.patch[i].patchFileName != "Untitled") { fileSaveAsm(bank.patch[i], asmFileName); spnFileNames[i] = asmFileName; } } catch (IOException e) { JOptionPane.showOptionDialog(null, "File save error!", "Error", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); e.printStackTrace(); } finally { } } // now create the Spin Project file fileToBeSaved.delete(); BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(fileToBeSaved, true)); } catch (IOException e1) { e1.printStackTrace(); } try { writer.write("NUMDOCS:8"); writer.newLine(); } catch (IOException e1) { e1.printStackTrace(); } for (int i = 0; i < 8; i++) { try { if (bank.patch[i].patchFileName != "Untitled") { writer.write(spnFileNames[i] + ",1"); } else { writer.write(",0"); } writer.newLine(); } catch (IOException e) { JOptionPane.showOptionDialog(null, "File save error!\n" + filePath, "Error", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); e.printStackTrace(); } } // write the build flags try { writer.write(",1,1,1"); writer.newLine(); } catch (IOException e1) { e1.printStackTrace(); } try { writer.close(); } catch (IOException e) { e.printStackTrace(); } saveMRUSpjFolder(filePath); } }
From source file:com.proyecto.vista.MantenimientoUnidadMedida.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = AbstractControlador.ELIMINAR; if (tblUnidad.getSelectedRow() != -1) { Integer id = tblUnidad.getSelectedRow(); UnidadMedida unidad = unidadControlador.buscarPorId(lista.get(id).getId()); if (unidad != null) { if (JOptionPane.showConfirmDialog(null, "Desea Eliminar la Unidad?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { int[] filas = tblUnidad.getSelectedRows(); for (int i = 0; i < filas.length; i++) { UnidadMedida unidad2 = lista.get(filas[0]); lista.remove(unidad2); unidadControlador.setSeleccionado(unidad2); unidadControlador.accion(accion); }// www. j a va 2 s .c om if (unidadControlador.accion(accion) == 3) { JOptionPane.showMessageDialog(null, "Unidad eliminada correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Unidad no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Unidad no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(null, "Debe seleccionar una Unidad de la lista", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } }
From source file:edu.harvard.mcz.imagecapture.MainFrame.java
/** * This method initializes jMenuItemPreprocess * //from w w w . j a v a 2 s .c o m * @return javax.swing.JMenuItem */ private JMenuItem getJMenuItemPreprocess() { if (jMenuItemPreprocess == null) { jMenuItemPreprocess = new JMenuItem(); jMenuItemPreprocess.setText("Preprocess All"); jMenuItemPreprocess.setEnabled(true); try { jMenuItemPreprocess.setIcon(new ImageIcon(this.getClass() .getResource("/edu/harvard/mcz/imagecapture/resources/barcode_icon_16px.jpg"))); } catch (Exception e) { log.error("Can't open icon file for jMenuItemScanOneBarcode."); log.error(e.getLocalizedMessage()); } jMenuItemPreprocess.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { int result = JOptionPane.showConfirmDialog(Singleton.getSingletonInstance().getMainFrame(), "Are you sure, this will check all image files and may take some time.", "Preprocess All?", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { JobAllImageFilesScan scan = new JobAllImageFilesScan(); (new Thread(scan)).start(); } else { Singleton.getSingletonInstance().getMainFrame().setStatusMessage("Preprocess canceled."); } } }); } return jMenuItemPreprocess; }
From source file:edu.ku.brc.specify.dbsupport.TaskSemaphoreMgr.java
/** * Locks the semaphore.// w w w.j a va2 s.c o m * @param title The human (localized) title of the task * @param name the unique name * @param context * @param scope the scope of the lock * @param allViewMode allows it to ask the user about 'View Only' * @return */ public static USER_ACTION lock(final String title, final String name, final String context, final SCOPE scope, final boolean allViewMode, final TaskSemaphoreMgrCallerIFace caller, final boolean checkUsage) { DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); int count = 0; do { SpTaskSemaphore semaphore = null; try { semaphore = setLock(session, name, context, scope, true, false, checkUsage); } catch (StaleObjectException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(TaskSemaphoreMgr.class, ex); semaphore = null; } if (semaphore == null || previouslyLocked) { if (caller != null) { return caller.resolveConflict(semaphore, previouslyLocked, prevLockedBy); } if (semaphore == null) { String msg = UIRegistry.getLocalizedMessage("SpTaskSemaphore.IN_USE", title);//$NON-NLS-1$ Object[] options = { getResourceString("SpTaskSemaphore.TRYAGAIN"), //$NON-NLS-1$ getResourceString("CANCEL") //$NON-NLS-1$ }; int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), msg, getResourceString("SpTaskSemaphore.IN_USE_TITLE"), //$NON-NLS-1$ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (userChoice == JOptionPane.NO_OPTION) { return USER_ACTION.Cancel; } } else { // Check to see if we have the same user on the same machine. SpecifyUser user = AppContextMgr.getInstance().getClassObject(SpecifyUser.class); String currMachineName = InetAddress.getLocalHost().toString(); String dbMachineName = semaphore.getMachineName(); //System.err.println("["+dbMachineName+"]["+currMachineName+"]["+user.getId()+"]["+semaphore.getOwner().getId()+"]"); if (StringUtils.isNotEmpty(dbMachineName) && StringUtils.isNotEmpty(currMachineName) && currMachineName.equals(dbMachineName) && semaphore.getOwner() != null && user != null && user.getId().equals(semaphore.getOwner().getId())) { if (allViewMode) { int options = JOptionPane.YES_NO_OPTION; Object[] optionLabels = new String[] { getResourceString("SpTaskSemaphore.VIEWMODE"), //$NON-NLS-1$ getResourceString("CANCEL")//$NON-NLS-1$ }; int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), getLocalizedMessage("SpTaskSemaphore.IN_USE_BY_YOU", title), getResourceString("SpTaskSemaphore.IN_USE_TITLE"), //$NON-NLS-1$ options, JOptionPane.QUESTION_MESSAGE, null, optionLabels, 0); return userChoice == JOptionPane.NO_OPTION ? USER_ACTION.Cancel : USER_ACTION.ViewMode; // CHECKED } int options = JOptionPane.OK_OPTION; Object[] optionLabels = new String[] { getResourceString("OK")//$NON-NLS-1$ }; JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), getLocalizedMessage("SpTaskSemaphore.IN_USE_BY_YOU", title), getResourceString("SpTaskSemaphore.IN_USE_TITLE"), //$NON-NLS-1$ options, JOptionPane.QUESTION_MESSAGE, null, optionLabels, 0); return USER_ACTION.Cancel; } String userStr = prevLockedBy != null ? prevLockedBy : semaphore.getOwner().getIdentityTitle(); String msgKey = allViewMode ? "SpTaskSemaphore.IN_USE_OV" : "SpTaskSemaphore.IN_USE"; String msg = UIRegistry.getLocalizedMessage(msgKey, title, userStr, semaphore.getLockedTime() != null ? semaphore.getLockedTime().toString() : ""); int options; int defBtn; Object[] optionLabels; if (allViewMode) { defBtn = 2; options = JOptionPane.YES_NO_CANCEL_OPTION; optionLabels = new String[] { getResourceString("SpTaskSemaphore.VIEWMODE"), //$NON-NLS-1$ getResourceString("SpTaskSemaphore.TRYAGAIN"), //$NON-NLS-1$ getResourceString("CANCEL")//$NON-NLS-1$ }; } else { defBtn = 0; options = JOptionPane.YES_NO_OPTION; optionLabels = new String[] { getResourceString("SpTaskSemaphore.TRYAGAIN"), //$NON-NLS-1$ getResourceString("CANCEL"), //$NON-NLS-1$ }; } int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), msg, getResourceString("SpTaskSemaphore.IN_USE_TITLE"), //$NON-NLS-1$ options, JOptionPane.QUESTION_MESSAGE, null, optionLabels, defBtn); if (userChoice == JOptionPane.YES_OPTION) { if (options == JOptionPane.YES_NO_CANCEL_OPTION) { return USER_ACTION.ViewMode; // CHECKED } // this means try again } else if (userChoice == JOptionPane.NO_OPTION) { if (options == JOptionPane.YES_NO_OPTION) { return USER_ACTION.Cancel; } // CHECKED } else if (userChoice == JOptionPane.CANCEL_OPTION) { return USER_ACTION.Cancel; // CHECKED } } } else { return USER_ACTION.OK; } count++; } while (true); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(TaskSemaphoreMgr.class, ex); ex.printStackTrace(); //log.error(ex); } finally { if (session != null) { session.close(); } } return USER_ACTION.Error; }
From source file:com.proyecto.vista.MantenimientoCampo.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = Controlador.ELIMINAR;// www . j a v a2s .co m 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); } 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:fi.hoski.remote.ui.Admin.java
private JMenuItem menuItemRemoveYear() { final String title = TextUtil.getText("REMOVE YEAR"); JMenuItem removeEntityItem = new JMenuItem(title); ActionListener removeEntityAction = new ActionListener() { @Override/*from w ww.ja va 2s . co m*/ public void actionPerformed(ActionEvent e) { Object yearString = JOptionPane.showInputDialog(frame, title, "", JOptionPane.OK_CANCEL_OPTION); if (yearString != null) { String confirm = TextUtil.getText("CONFIRM REMOVE") + " " + yearString; if (JOptionPane.showConfirmDialog(frame, confirm, "", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { long year = Long.parseLong(yearString.toString()); Day now = new Day(); if (year < now.getYear()) { int count = dss.remove(year); JOptionPane.showMessageDialog(frame, TextUtil.getText("REMOVED") + " " + count); } else { JOptionPane.showMessageDialog(frame, TextUtil.getText("CANNOT REMOVE") + " " + year); } } } } }; removeEntityAction = createActionListener(frame, removeEntityAction); removeEntityItem.addActionListener(removeEntityAction); return removeEntityItem; }
From source file:edu.ku.brc.af.ui.forms.IconViewObj.java
/** * //w ww .j a va2 s. c om */ protected void doDelete() { FormDataObjIFace dataObj = iconTray.getSelection(); if (dataObj != null) { Object[] delBtnLabels = { getResourceString("Delete"), getResourceString("CANCEL") }; int rv = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), UIRegistry.getLocalizedMessage("ASK_DELETE", dataObj.getIdentityTitle()), getResourceString("Delete"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, delBtnLabels, delBtnLabels[1]); if (rv == JOptionPane.YES_OPTION) { iconTray.removeItem(dataObj); parentDataObj.removeReference(dataObj, IconViewObj.this.cellName); if (mvParent != null) { MultiView topLvl = mvParent.getTopLevel(); topLvl.addDeletedItem(dataObj); rootHasChanged(); } iconTray.repaint(); updateEnableUI(); rootHasChanged(); } } }