List of usage examples for javax.swing JOptionPane DEFAULT_OPTION
int DEFAULT_OPTION
To view the source code for javax.swing JOptionPane DEFAULT_OPTION.
Click Source Link
JOptionPane
. From source file:de.juwimm.cms.content.panel.PanDocuments.java
private void btnDeleteActionPerformed(ActionEvent e) { try {//from www. j a v a2 s . c o m DocumentSlimValue currDoc = null; String acc = bgrp.getSelection().getActionCommand(); int rowInModel = tblDocumentsModel.getRowForDocument(Integer.valueOf(acc)); if (rowInModel >= 0) { currDoc = (DocumentSlimValue) tblDocumentsModel.getValueAt(rowInModel, 4); } String tmp = acc; if (currDoc != null && currDoc.getDocumentName() != null && !"".equalsIgnoreCase(currDoc.getDocumentName())) { tmp += " (" + currDoc.getDocumentName() + ")"; } /* if (currDoc != null && (currDoc.getUseCountLastVersion() + currDoc.getUseCountPublishVersion()) > 0) { JOptionPane.showMessageDialog(this, SwingMessages.getString("panel.content.documents.deleteButInUse", tmp), SwingMessages.getString("panel.content.documents.deleteDocument"), JOptionPane.WARNING_MESSAGE); return; } */ int ret = JOptionPane.showConfirmDialog(this, Messages.getString("panel.content.documents.deleteThisDocument", tmp), Messages.getString("panel.content.documents.deleteDocument"), JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); if (ret == JOptionPane.YES_OPTION) { comm.removeDocument(Integer.valueOf(acc).intValue()); loadThumbs(((CboModel) this.cboRegion.getSelectedItem()).getRegionId()); } } catch (NullPointerException ex) { } catch (Exception ex) { if (ex.getMessage().contains("validation exception")) { JOptionPane.showConfirmDialog(this, rb.getString("panel.content.documents.delete.exception"), rb.getString("panel.content.documents.deleteDocument"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else { log.warn("exception on delete document"); if (log.isDebugEnabled()) { log.debug(ex); } } } }
From source file:com.pironet.tda.TDA.java
private void saveSession() { initSessionFc();//ww w .j av a 2 s . c o m int returnVal = sessionFc.showSaveDialog(this.getRootPane()); sessionFc.setPreferredSize(sessionFc.getSize()); PrefManager.get().setPreferredSizeFileChooser(sessionFc.getSize()); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = sessionFc.getSelectedFile(); // check if file has a suffix if (!file.getName().contains(".")) { file = new File(file.getAbsolutePath() + ".tsf"); } int selectValue = 0; if (file.exists()) { Object[] options = { "Overwrite", "Cancel" }; selectValue = JOptionPane.showOptionDialog(null, "<html><body>File exists<br><b>" + file + "</b></body></html>", "Confirm overwrite", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); } if (selectValue == 0) { ObjectOutputStream oos = null; try { oos = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(file))); oos.writeObject(dumpFile); oos.writeObject(topNodes); oos.writeObject(dumpStore); } catch (IOException ex) { ex.printStackTrace(); } finally { IOUtils.closeQuietly(oos); } PrefManager.get().addToRecentSessions(file.getAbsolutePath()); } } }
From source file:com.att.aro.ui.view.MainFrame.java
@Override public void updateCollectorStatus(CollectorStatus collectorStatus, StatusResult statusResult) { this.collectorStatus = collectorStatus; if (statusResult == null) { return;/*from ww w. j a va 2 s .c om*/ } log.info("updateCollectorStatus :STATUS :" + statusResult); // timeout - collection not approved in time if (!statusResult.isSuccess()) { //String traceFolder = aroController.getTraceFolderPath(); log.info("updateCollectorStatus :FAILED STATUS :" + statusResult.getError().getDescription()); if (statusResult.getError().getCode() == 206) { int option = MessageDialogFactory.getInstance().showStopDialog(window.getJFrame(), statusResult.getError().getDescription(), BUNDLE.getString("error.title"), JOptionPane.DEFAULT_OPTION); if (option == JOptionPane.YES_NO_OPTION || CollectorStatus.CANCELLED == collectorStatus) { cancelCollector(); } } else { MessageDialogFactory.getInstance().showErrorDialog(window.getJFrame(), statusResult.getError().getDescription()); } return; } // Collection has been stopped ask to open trace if (collectorStatus != null && collectorStatus.equals(CollectorStatus.STOPPED)) { stopCollectorWorker.hideProgressDialog(); log.info("stopDialog"); String traceFolder = aroController.getTraceFolderPath(); int seconds = (int) (aroController.getTraceDuration() / 1000); boolean approveOpenTrace = MessageDialogFactory.getInstance().showTraceSummary( frmApplicationResourceOptimizer, traceFolder, !aroController.getVideoOption().equals(VideoOption.NONE), Util.formatHHMMSS(seconds)); if (approveOpenTrace) { updateTracePath(new File(aroController.getTraceFolderPath())); } return; } }
From source file:com.paniclauncher.data.Settings.java
public void rotateLogFiles() { File logFile1 = new File(getBaseDir(), "PanicLauncher-Log-1.txt"); File logFile2 = new File(getBaseDir(), "PanicLauncher-Log-2.txt"); File logFile3 = new File(getBaseDir(), "PanicLauncher-Log-3.txt"); if (logFile3.exists()) { Utils.delete(logFile3);/*from www . ja v a 2 s .c o m*/ } if (logFile2.exists()) { logFile2.renameTo(logFile3); } if (logFile1.exists()) { logFile1.renameTo(logFile2); } try { logFile1.createNewFile(); } catch (IOException e) { String[] options = { "OK" }; JOptionPane.showOptionDialog(null, "<html><center>Cannot create the log file.<br/><br/>Make sure" + " you are running the Launcher from somewhere with<br/>write" + " permissions for your user account such as your Home/Users folder" + " or desktop.</center></html>", "Warning", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[0]); System.exit(0); } }
From source file:Citas.FrameCita.java
public void actionPerformed(ActionEvent e) { if (e.getSource() == agregarB) { try {//from w ww .j av a 2s . com //Cita JSONObject cita = new JSONObject(); cita.put("fecha", fechaJ.getText()); cita.put("hora", horaJ.getText()); cita.put("paciente", 3); cita.put("medicos", "1"); cita.put("tratamiento", "tratamiento"); cita.put("diagnostico", "diagnostico"); cita.put("motivo", motivosTA.getText()); System.out.print(cita); //Paciente JSONObject paciente = new JSONObject(); paciente.put("cedula", cedulaJ.getText()); paciente.put("nombre", nombreJ.getText()); paciente.put("apellido", apellidoJ.getText()); paciente.put("direccion", direccionJ.getText()); paciente.put("correo", correoJ.getText()); paciente.put("tlfncasa", telefonoCasaJ.getText()); paciente.put("tlfncelular", telefonoCelularJ.getText()); System.out.print(paciente); //rutasAdd.add("http://localhost/API_Citas/public/Pacientes/insertarPaciente", paciente); rutasAdd.add("http://localhost/API_Citas/public/Citas/insertarCita", cita); setCitas(); } catch (IOException ex) { Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex); } catch (JSONException ex) { Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex); } catch (ParseException ex) { Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex); } catch (java.text.ParseException ex) { Logger.getLogger(FrameCita.class.getName()).log(Level.SEVERE, null, ex); } return; } if (e.getSource() == modificarB) { return; } if (e.getSource() == eliminarB) { return; } if (e.getSource() == atrasB) { } if (e.getSource() == buscarB) { String[] opciones = { "Aceptar" }; int opcion = JOptionPane.showOptionDialog(null //componente , "Cedula no pertenece a ningun paciente registrado" // Mensaje , "Paciente no encontrado" // Titulo en la barra del cuadro , JOptionPane.DEFAULT_OPTION // Tipo de opciones , JOptionPane.WARNING_MESSAGE // Tipo de mensaje (icono) , null // Icono (ninguno) , opciones // Opciones personalizadas , null // Opcion por defecto ); } }
From source file:DragDropTreeExample.java
protected void transferFile(int action, File srcFile, File targetDirectory, FileTree.FileTreeNode targetNode) { DnDUtils.debugPrintln((action == DnDConstants.ACTION_COPY ? "Copy" : "Move") + " file " + srcFile.getAbsolutePath() + " to " + targetDirectory.getAbsolutePath()); // Create a File entry for the target String name = srcFile.getName(); File newFile = new File(targetDirectory, name); if (newFile.exists()) { // Already exists - is it the same file? if (newFile.equals(srcFile)) { // Exactly the same file - ignore return; }//from w ww . j a v a 2s . c om // File of this name exists in this directory if (copyOverExistingFiles == false) { int res = JOptionPane.showOptionDialog(tree, "A file called\n " + name + "\nalready exists in the directory\n " + targetDirectory.getAbsolutePath() + "\nOverwrite it?", "File Exists", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Yes", "Yes to All", "No", "Cancel" }, "No"); switch (res) { case 1: // Yes to all copyOverExistingFiles = true; case 0: // Yes break; case 2: // No return; default: // Cancel throw new IllegalStateException("Cancelled"); } } } else { // New file - create it try { newFile.createNewFile(); } catch (IOException e) { JOptionPane.showMessageDialog(tree, "Failed to create new file\n " + newFile.getAbsolutePath(), "File Creation Failed", JOptionPane.ERROR_MESSAGE); return; } } // Copy the data and close file. BufferedInputStream is = null; BufferedOutputStream os = null; try { is = new BufferedInputStream(new FileInputStream(srcFile)); os = new BufferedOutputStream(new FileOutputStream(newFile)); int size = 4096; byte[] buffer = new byte[size]; int len; while ((len = is.read(buffer, 0, size)) > 0) { os.write(buffer, 0, len); } } catch (IOException e) { JOptionPane.showMessageDialog(tree, "Failed to copy file\n " + name + "\nto directory\n " + targetDirectory.getAbsolutePath(), "File Copy Failed", JOptionPane.ERROR_MESSAGE); return; } finally { try { if (is != null) { is.close(); } if (os != null) { os.close(); } } catch (IOException e) { } } // Remove the source if this is a move operation. if (action == DnDConstants.ACTION_MOVE && System.getProperty("DnDExamples.allowRemove") != null) { srcFile.delete(); } // Update the tree display if (targetNode != null) { tree.addNode(targetNode, name); } }
From source file:com.paniclauncher.data.Settings.java
/** * Load the users Console preference from file *//*from ww w . j a v a 2 s. c o m*/ public void loadStartingProperties() { try { if (!propertiesFile.exists()) { propertiesFile.createNewFile(); } } catch (IOException e) { String[] options = { "OK" }; JOptionPane.showOptionDialog(null, "<html><center>Cannot create the config file.<br/><br/>Make sure" + " you are running the Launcher from somewhere with<br/>write" + " permissions for your user account such as your Home/Users folder" + " or desktop.</center></html>", "Warning", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[0]); System.exit(0); } try { this.properties.load(new FileInputStream(propertiesFile)); this.enableConsole = Boolean.parseBoolean(properties.getProperty("enableconsole", "true")); this.enableDebugConsole = Boolean.parseBoolean(properties.getProperty("enabledebugconsole", "false")); this.javaPath = properties.getProperty("javapath", Utils.getJavaHome()); } catch (FileNotFoundException e) { this.console.logStackTrace(e); } catch (IOException e) { this.console.logStackTrace(e); } }
From source file:com.atlauncher.data.Settings.java
private void checkForLauncherUpdate() { LogManager.debug("Checking for launcher update"); if (launcherHasUpdate()) { if (!App.wasUpdated) { downloadUpdate(); // Update the Launcher } else {// w w w.j a v a 2 s .c o m String[] options = { "Ok" }; JOptionPane.showOptionDialog(App.settings.getParent(), HTMLUtils.centerParagraph("Update failed. " + "Please click Ok to close " + "the launcher and open up the downloads " + "page.<br/><br/>Download " + "the update and replace the old ATLauncher file."), "Update Failed!", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[0]); Utils.openBrowser("http://www.atlauncher.com/downloads/"); System.exit(0); } } else if (Constants.VERSION.isBeta() && launcherHasBetaUpdate()) { downloadBetaUpdate(); } LogManager.debug("Finished checking for launcher update"); }
From source file:com.iucosoft.eavertizare.gui.MainJFrame.java
private void jButtonExportPdfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExportPdfActionPerformed Vector element = new Vector(); for (int i = 0; i < firmeListModel.getSize(); i++) { element.add(firmeListModel.getElementAt(i)); }/*from www. ja v a 2s . co m*/ final JComboBox<String> combo = new JComboBox<>(element); String[] options = { "OK", "Cancel" }; String title = "Selctati firma!"; int selection = JOptionPane.showOptionDialog(null, combo, title, JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, element.get(0)); try { if (options[selection].equals("OK")) { Object firmaSelectata = combo.getSelectedItem(); if (firmaSelectata.equals("All firms")) { clientiTableModel.refreshModel(); } else { clientiTableModel.refreshModel((String) firmaSelectata); } Export.toPdf(this, jTableClients, (String) firmaSelectata); clientiTableModel.refreshModel(); } } catch (Exception e) { } }
From source file:de.dmarcini.submatix.pclogger.gui.MainCommGUI.java
/** * Hilfsfunktion zum start speichern/update eines Tauchlogs Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui * /*from ww w . jav a 2 s . co m*/ * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 12.07.2012 * @param logListEntry */ private int computeLogRequest(Integer[] logListEntry) { // liegt ein updatewunsch vor? if (logListEntry[1] > 0) { lg.warn("dive logentry alredy there. Ask user for continue..."); //@formatter:off // Zeige dem geneigten User eine Dialogbox, in welcher er entscheiden muss: Update oder berspringen Object[] options = { LangStrings.getString("MainCommGUI.updateWarnDialog.updateButton"), LangStrings.getString("MainCommGUI.updateWarnDialog.cancelButton") }; int retOption = JOptionPane.showOptionDialog(null, LangStrings.getString("MainCommGUI.updateWarnDialog.messageUpdate"), LangStrings.getString("MainCommGUI.updateWarnDialog.headLine"), JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); //@formatter:on if (retOption == 1) { lg.info("user has cancel to update divelog entry."); return (0); } else { // update datensatz! logListPanel.setNextLogIsAnUpdate(true, logListEntry[0]); } } // datensatz anlegen wDial = new PleaseWaitDialog(LangStrings.getString("PleaseWaitDialog.title"), LangStrings.getString("PleaseWaitDialog.waitForReadDive")); wDial.setDetailMessage( String.format(LangStrings.getString("PleaseWaitDialog.readDiveNumber"), logListEntry[0])); wDial.setTimeout(90 * 1000); wDial.setVisible(true); // Sag dem SPX er soll alles schicken lg.debug("send command to spx: send logfile number <" + logListEntry[0] + ">"); btComm.readLogDetailFromSPX(logListEntry[0]); return (1); }