List of usage examples for javax.swing JOptionPane showConfirmDialog
public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType) throws HeadlessException
optionType
parameter. 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 */// w w w. j a va 2s. c o m 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 . jav a2 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: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 w w w. j a v a 2 s . com * * @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:gui.DownloadPanel.java
public void actionReDownload() { int action = JOptionPane.showConfirmDialog(parent, "Do you realy want to redownload the file?", "Confirm Redownload", JOptionPane.OK_CANCEL_OPTION); if (action == JOptionPane.OK_OPTION) { Download newDownload = selectedDownload; try {// ww w. ja va 2s .c om FileUtils.forceDelete(new File(selectedDownload.getDownloadRangePath() + File.separator + selectedDownload.getDownloadName())); // todo must again } catch (IOException e) { e.printStackTrace(); } if (newDownload.getStatus() == DownloadStatus.COMPLETE) { newDownload.resetData(); newDownload.resume(); tableSelectionChanged(); } } }
From source file:com.alvermont.terraj.stargen.ui.SystemFrame.java
private void saveMenuItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_saveMenuItemActionPerformed {//GEN-HEADEREND:event_saveMenuItemActionPerformed final int choice = this.pngChooser.showSaveDialog(this); try {//from w w w.ja va 2 s. c o m if (choice == JFileChooser.APPROVE_OPTION) { if (!this.pngChooser.getSelectedFile().isFile() || (JOptionPane.showConfirmDialog(this, "This file already exists. Do you want to\n" + "overwrite it?", "Replace File?", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)) { List<BufferedImage> images = UIUtils.getPlanetImages(this.planets); BufferedImage collage = UIUtils.combineImagesHorizontal(images); final File target = FileUtils.addExtension(this.pngChooser.getSelectedFile(), ".png"); ImageIO.write(collage, PNGFileFilter.getFormatName(target), target); } } } catch (IOException ioe) { log.error("Error writing image file", ioe); JOptionPane.showMessageDialog(this, "Error: " + ioe.getMessage() + "\nCheck log file for full details", "Error Saving", JOptionPane.ERROR_MESSAGE); } }
From source file:com.net2plan.gui.tools.GUINetworkDesign.java
private void resetButton() { try {/*from w ww . ja v a2 s . co m*/ final int result = JOptionPane.showConfirmDialog(null, "Are you sure you want to reset? This will remove all unsaved data", "Reset", JOptionPane.YES_NO_OPTION); if (result != JOptionPane.YES_OPTION) return; if (inOnlineSimulationMode()) { switch (onlineSimulationPane.getSimKernel().getSimCore().getSimulationState()) { case NOT_STARTED: case STOPPED: break; default: onlineSimulationPane.getSimKernel().getSimCore().setSimulationState(SimState.STOPPED); break; } onlineSimulationPane.getSimKernel().reset(); setCurrentNetPlanDoNotUpdateVisualization(onlineSimulationPane.getSimKernel().getCurrentNetPlan()); } else { setCurrentNetPlanDoNotUpdateVisualization(new NetPlan()); //algorithmSelector.reset(); executionPane.reset(); } // reportSelector.reset(); // reportContainer.removeAll(); } catch (Throwable ex) { ErrorHandling.addErrorOrException(ex, GUINetworkDesign.class); ErrorHandling.showErrorDialog("Unable to reset"); } Pair<BidiMap<NetworkLayer, Integer>, Map<NetworkLayer, Boolean>> res = VisualizationState .generateCanvasDefaultVisualizationLayerInfo(getDesign()); vs.setCanvasLayerVisibilityAndOrder(getDesign(), res.getFirst(), res.getSecond()); updateVisualizationAfterNewTopology(); undoRedoManager.addNetPlanChange(); }
From source file:com.proyecto.vista.MantenimientoArea.java
private void btnguardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnguardarActionPerformed // TODO add your handling code here: List<Integer> array = new ArrayList(); array.add(FormularioUtil.Validar(FormularioUtil.TipoValidacion.NUMERO, this.nombreField, "Nombre")); FormularioUtil.validar2(array);/*from ww w . ja va2 s . c o m*/ if (FormularioUtil.error) { JOptionPane.showMessageDialog(null, FormularioUtil.mensaje, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); FormularioUtil.mensaje = ""; FormularioUtil.error = false; } else { String palabra = ""; String palabra2 = ""; if (accion == 1) { palabra = "registrar"; palabra2 = "registrado"; if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " la Area?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { areaControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase()); areaControlador.accion(accion); lista.add(areaControlador.getSeleccionado()); if (accion == 1) { JOptionPane.showMessageDialog(null, "Area " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); FormularioUtil.limpiarComponente(panelDatos); } else { JOptionPane.showMessageDialog(null, "Area no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { FormularioUtil.limpiarComponente(panelDatos); JOptionPane.showMessageDialog(null, "Area no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else if (accion == 2) { palabra = "modificar"; palabra2 = "modificado"; if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " la Area?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { if (accion == 2) { JOptionPane.showMessageDialog(null, "Area " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); lista.clear(); areaControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase()); areaControlador.accion(accion); listar(); FormularioUtil.limpiarComponente(panelDatos); } else { JOptionPane.showMessageDialog(null, "Area no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { FormularioUtil.limpiarComponente(panelDatos); JOptionPane.showMessageDialog(null, "Area no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } FormularioUtil.activarComponente(panelOpciones, true); FormularioUtil.activarComponente(panelGuardar, false); FormularioUtil.activarComponente(panelDatos, false); } }
From source file:de.quadrillenschule.azocamsyncd.gui.ConfigurationWizardJFrame.java
private void checkConnectionjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkConnectionjButtonActionPerformed FTPConnection f = new FTPConnection(); f.setPossibleConnections(gp.getProperty(CamSyncProperties.SDCARD_IPS).split(",")); f.setFileTypes(gp.getProperty(CamSyncProperties.FILETYPES).split(",")); boolean success = false; success = f.checkConnection(true).size() > 0; if (success) { JOptionPane.showMessageDialog(rootPane, "The connection to your SD card was estabilshed.", "Success!", JOptionPane.INFORMATION_MESSAGE); step1jCheckBox.setSelected(true); step1jCheckBox.setText("Connection OK"); updateSelectedPanel(2);/*from w w w.j a v a 2 s.c o m*/ } else { JOptionPane.showConfirmDialog(rootPane, "The connection to the WiFi SD card failed. Please check, if it is on power and the IPs are correct.", "Connection to SD card failed", JOptionPane.WARNING_MESSAGE); } }
From source file:fs.MainWindow.java
public void ExecuteFeatureSelection(int selector) throws IOException { String penalization_type = (String) jCB_PenalizationSE.getSelectedItem(); float alpha = ((Double) jS_AlphaSE.getValue()).floatValue(); float q_entropy = ((Double) jS_QEntropySE.getValue()).floatValue(); float beta = ((float) jSliderBetaSE.getValue() / 100); //if selected criterion function is CoD, q_entropy = 0 if (jCB_CriterionFunctionSE.getSelectedIndex() == 1) { q_entropy = 0;/* w ww . ja v a 2 s. c om*/ } //CoD if (q_entropy < 0 || alpha < 0) { //entrada de dados invalida. JOptionPane.showMessageDialog(this, "Error on parameter value:The" + " values of q-entropy and Alpha must be positives.", "Application Error", JOptionPane.ERROR_MESSAGE); return; } jTA_SaidaSE.setText(""); jTA_SelectedFeaturesSE.setText(""); // n = quantidade de valores assumidos pelas caracteristicas. int n = Main.maximumValue(Md, 0, lines - 1, 0, columns - 2) + 1; //c = numero de rotulos possiveis para as classes. int c = Main.maximumValue(Md, 0, lines - 1, columns - 1, columns - 1) + 1; jProgressBarSE.setValue(5); Thread.yield(); char[][] strainingset = MathRoutines.float2char(Md); char[][] stestset = null; if (!jTF_InputTestSE.getText().equals("")) { stestset = IOFile.readMatrix(jTF_InputTestSE.getText(), delimiter); } else { stestset = MathRoutines.float2char(Md); } int resultsetsize = 1; try { //vetor com os resultados da selecao de caracteristica. resultsetsize = (Integer) jS_MaxResultListSE.getValue(); if (resultsetsize < 1) { Thread.yield(); JOptionPane .showMessageDialog(this, "Error on parameter value:" + " The Size of the Result List must be a integer value" + " greater or equal to 1.", "Application Error", JOptionPane.ERROR_MESSAGE); return; } } catch (NumberFormatException error) { Thread.yield(); JOptionPane.showMessageDialog( this, "Error on parameter value: The" + " Size of the Result List must be a integer value greater" + " or equal to 1.", "Application Error", JOptionPane.ERROR_MESSAGE); return; } /* SELETOR DE CARACTERISTICAS PARA O TREINAMENTO. */ FS fs = new FS(strainingset, n, c, penalization_type, alpha, beta, q_entropy, resultsetsize); jProgressBarSE.setValue(10); Thread.yield(); int maxfeatures = (Integer) jS_MaxSetSizeSE.getValue(); if (maxfeatures <= 0) { JOptionPane.showMessageDialog(this, "Error on parameter value: The" + " Maximum Set Size be a integer value greater" + " or equal to 1.", "Application Error", JOptionPane.ERROR_MESSAGE); return; } if (selector == 1) { fs.runSFS(false, maxfeatures); jProgressBarSE.setValue(90); Thread.yield(); } else if (selector == 3) { fs.runSFFS(maxfeatures, -1, null); jProgressBarSE.setValue(90); Thread.yield(); } else if (selector == 2) { fs.runSFS(true, maxfeatures); /* a call to SFS is made in order to get the //ideal dimension to run the exhaustive search;*/ int itmax = fs.itmax; if (itmax < maxfeatures) { itmax = maxfeatures; } /*calculating the estimated time to be completed in rea computer of 2 GHz*/ int combinations = 0; for (int i = 1; i <= itmax; i++) { combinations += MathRoutines.numberCombinations(columns - 1, i); } double estimatedTime = (0.0062 + 3.2334e-7 * strainingset.length) * combinations * Math.log(combinations) / Math.log(2); int answer = JOptionPane.showConfirmDialog(null, "Estimated " + "time to finish: " + estimatedTime + " s.\n Do you want to" + " continue?", "Exhaustive Search", JOptionPane.YES_NO_OPTION); if (answer == 1) { jProgressBarSE.setValue(0); return; } //System.out.println("Estimated time to finish: "+estimatedTime+" s"); float new_itmax = itmax; FS fsPrev = new FS(strainingset, n, c, penalization_type, alpha, beta, q_entropy, resultsetsize); for (int i = 1; i <= itmax; i++) { System.out.println("Iteration " + i); fs = new FS(strainingset, n, c, penalization_type, alpha, beta, q_entropy, resultsetsize); fs.itmax = i; fs.runExhaustive(0, 0, fs.I); //if (fs.hGlobal == 0) { // break; //} if (fs.hGlobal < fsPrev.hGlobal) { fsPrev = fs; } else { fs = fsPrev; break; } float new_i = i; float pb = (new_i / new_itmax); pb = (pb * 80.0f); jProgressBarSE.setValue(10 + (int) pb); Thread.yield(); } } /* jTA_SelectedFeaturesSE.setText("1st Global Criterion Function Value: " + fs.hGlobal); jTA_SelectedFeaturesSE.append("\nSelected Features: "); for (int i = 0; i < fs.I.size(); i++) { jTA_SelectedFeaturesSE.append(fs.I.elementAt(i) + " "); } * substituido pelo codigo abaixo para exibir uma lista de resultados * de tamanho escolhido pelo usuario. */ for (int i = 0; i < fs.resultlist.size(); i++) { float fsvalue = ((Float) fs.resultlist.get(i).get(0)); if (i == 0) { jTA_SelectedFeaturesSE.setText((i + 1) + "st Global Criterion" + " Function Value: " + fsvalue); } else if (i == 1) { jTA_SelectedFeaturesSE .append("\n\n" + (i + 1) + "nd Global" + " Criterion Function Value: " + fsvalue); } else if (i == 2) { jTA_SelectedFeaturesSE .append("\n\n" + (i + 1) + "rd Global" + " Criterion Function Value: " + fsvalue); } else { jTA_SelectedFeaturesSE .append("\n\n" + (i + 1) + "th Global" + " Criterion Function Value: " + fsvalue); } jTA_SelectedFeaturesSE.append("\nSelected Features: "); Vector features = (Vector) fs.resultlist.get(i).get(1); for (int j = 0; j < features.size(); j++) { jTA_SelectedFeaturesSE.append((Integer) features.get(j) + " "); } } // CLASSIFICADOR. Classifier clas = new Classifier(); clas.classifierTable(strainingset, fs.I, n, c); for (int i = 0; i < clas.table.size(); i++) { double[] tableLine = (double[]) clas.table.elementAt(i); double instance = (Double) clas.instances.elementAt(i); System.out.print(instance + " "); for (int j = 0; j < c; j++) { System.out.print((int) tableLine[j] + " "); } System.out.println(); } jProgressBarSE.setValue(95); Thread.yield(); double[] instances = clas.classifyTestSamples(stestset, fs.I, n, c); jTA_SaidaSE.setText("Correct Labels - Classified Labels - " + "Classification Instances\n(Considering the first selected" + " features)\n"); double hits = 0; for (int i = 0; i < clas.labels.length; i++) { int correct_label = (int) stestset[i][columns - 1]; int classified_label = (int) clas.labels[i]; jTA_SaidaSE.append("\n" + correct_label + " - " + classified_label + " - " + instances[i]); if (correct_label == classified_label) { hits++; } Thread.yield(); } double hit_rate = hits / clas.labels.length; jTA_SaidaSE.append("\nrate of hits = " + hit_rate); jProgressBarSE.setValue(100); Thread.yield(); }
From source file:org.gumtree.vis.awt.CompositePanel.java
/** * Opens a file chooser and gives the user an opportunity to save the chart * in PNG format.// www. j av a 2 s .c o m * * @throws IOException if there is an I/O error. */ @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); } } ExtensionFileFilter pngFilter = new ExtensionFileFilter("PNG_Image_Files", ".png"); ExtensionFileFilter jpgFilter = new ExtensionFileFilter("JPG_Image_Files", ".jpg"); fileChooser.addChoosableFileFilter(pngFilter); fileChooser.addChoosableFileFilter(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"; } } 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()); } } }