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:uk.co.markfrimston.tasktree.Main.java
@Override public boolean confirmMerge() { return JOptionPane.showConfirmDialog(this, "Was the merge completed successfully?", "Merge", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION; }
From source file:com.biosis.biosislite.vistas.inventario.MantenimientoCampo.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 (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Campo?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { campoControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase()); campoControlador.getSeleccionado().setClase((Clase) cmbClase.getSelectedItem()); // campoControlador.getSeleccionado().setUnidadMedida((UnidadMedida) cmbUnidad.getSelectedItem()); campoControlador.accion(accion); lista.add(campoControlador.getSeleccionado()); if (accion == 1) { JOptionPane.showMessageDialog(null, "Campo " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); FormularioUtil.limpiarComponente(panelDatos); } else { JOptionPane.showMessageDialog(null, "Campo no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); }// www .jav a 2 s . c o m } else { FormularioUtil.limpiarComponente(panelDatos); JOptionPane.showMessageDialog(null, "Campo no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else if (accion == 2) { palabra = "modificar"; palabra2 = "modificado"; if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Campo?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { if (accion == 2) { JOptionPane.showMessageDialog(null, "Campo " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); lista.clear(); campoControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase()); campoControlador.getSeleccionado().setClase((Clase) cmbClase.getSelectedItem()); // campoControlador.getSeleccionado().setUnidadMedida((UnidadMedida) cmbUnidad.getSelectedItem()); campoControlador.accion(accion); listar(); FormularioUtil.limpiarComponente(panelDatos); } else { JOptionPane.showMessageDialog(null, "Campo no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { FormularioUtil.limpiarComponente(panelDatos); JOptionPane.showMessageDialog(null, "Campo no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } FormularioUtil.activarComponente(panelOpciones, true); FormularioUtil.activarComponente(panelGuardar, false); FormularioUtil.activarComponente(panelDatos, false); }
From source file:serial.ChartFromSerial.java
private void connect_jBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connect_jBtnActionPerformed defaultSeries.clear();/*from w w w. j a v a2s.c o m*/ text.setText(""); if ("Connect".equals(connect_jBtn.getText())) { //Attempt to connect to to serial port chosenPort = SerialPort.getCommPort(portList_jCombo.getSelectedItem().toString()); chosenPort.setComPortTimeouts(SerialPort.TIMEOUT_SCANNER, 0, 0); chosenPort.setBaudRate(Integer.parseInt(baudRate_jCombo.getSelectedItem().toString())); if (chosenPort.openPort()) { createSerialThread(chosenPort); buttonsConnected(); // if(createSerialThread(chosenPort)){ // buttonsConnected(); // } else { // JOptionPane.showMessageDialog(rootPane, "Failed to create a serial connection.", "Serial connection failed.", JOptionPane.ERROR_MESSAGE); // chosenPort.closePort(); // } } else { if (JOptionPane.showConfirmDialog(rootPane, "Error at " + portList_jCombo.getSelectedItem().toString() + "\nWould you like to refresh?", "Trouble connecting to " + portList_jCombo.getSelectedItem().toString(), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE) == JOptionPane.YES_OPTION) { hardRefresh(); } else { buttonsOff(); } } } else { //Attempt to disconnect from the serial port chosenPort.closePort(); softRefresh(); samples = 0; } }
From source file:MstrPetugas.FormPetugas.java
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed String kode = tabel_petugas.getValueAt(tabel_petugas.getSelectedRow(), 0).toString(); int jawab = JOptionPane.showConfirmDialog(this, "Hapus ? Data Petugas : " + kode, "Konfirmasi", JOptionPane.YES_NO_OPTION); if (jawab == JOptionPane.YES_OPTION) { MstrPetugas x = new MstrPetugas(); x.Delete(kode);/*from w w w. j ava 2 s .c o m*/ LoadData(); } }
From source file:com.nwn.NwnUpdaterHomeView.java
/** * Delete server from gui and config/*from www . ja v a 2 s . co m*/ * Currently this cannot be undone * @param evt */ private void btnRemoveServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveServerActionPerformed ServerInfo selectedServer = (ServerInfo) cmbServerList.getSelectedItem(); int confirm = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete " + selectedServer.getServerName() + "?", "Warning", JOptionPane.YES_NO_OPTION); if (confirm == JOptionPane.YES_OPTION) { config.getServerList().remove(cmbServerList.getSelectedItem()); cmbServerList.removeItemAt(cmbServerList.getSelectedIndex()); config.save(); } }
From source file:com.holycityaudio.SpinCAD.SpinCADFile.java
public void fileSaveBankAs(SpinCADBank b) { // Create a file chooser String savedPath = prefs.get("MRUBankFolder", ""); final JFileChooser fc = new JFileChooser(savedPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("SpinCAD Bank Files", "spbk"); fc.setFileFilter(filter);/*from w w w . j ava 2 s . c o m*/ fc.setSelectedFile(new File(b.bankFileName)); int returnVal = fc.showSaveDialog(new JFrame()); // need to process user canceling box right here if (returnVal == JFileChooser.APPROVE_OPTION) { // In response to a button click: File fileToBeSaved = fc.getSelectedFile(); if (!fc.getSelectedFile().getAbsolutePath().endsWith(".spbk")) { fileToBeSaved = new File(fc.getSelectedFile() + ".spbk"); } b.bankFileName = fileToBeSaved.getName(); int n = JOptionPane.YES_OPTION; if (fileToBeSaved.exists()) { JFrame frame = new JFrame(); n = JOptionPane.showConfirmDialog(frame, "Would you like to overwrite it?", "File already exists!", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { try { fileSaveBank(b); } finally { } } } else { fileSaveBank(b); } b.changed = false; recentBankFileList.add(fileToBeSaved); saveMRUBankFolder(fileToBeSaved.getPath()); b.bankFileName = fileToBeSaved.getName(); } }
From source file:dylemator.UserResultList.java
private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed int row = this.codeTable.getSelectedRow(); if (row == -1) return;/*w w w.ja va 2s . c om*/ String[] values = exportData.get(row + 1); int dialogResult = JOptionPane.showConfirmDialog(null, "Usun wyniki uytkownika " + values[0] + "?", "Warning", JOptionPane.YES_NO_OPTION); if (dialogResult == JOptionPane.YES_OPTION) { exportData.remove(row + 1); DefaultTableModel m = (DefaultTableModel) codeTable.getModel(); m.setRowCount(0); for (int i = 1; i < exportData.size(); i++) { m.addRow(new String[] { exportData.get(i)[0] }); } DefaultTableModel n = (DefaultTableModel) infoTable.getModel(); DefaultTableModel o = (DefaultTableModel) resultsTable.getModel(); n.setRowCount(0); o.setRowCount(0); try { OutputStreamWriter output = new FileWriter(this.selectedFilename); BufferedWriter bufferWriter = new BufferedWriter(output); for (String[] v : exportData) { String s = StringUtils.join(v, ";"); bufferWriter.write(s + "\n"); } bufferWriter.flush(); bufferWriter.close(); } catch (IOException ex) { Logger.getLogger(UserResultList.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.biosis.biosislite.vistas.inventario.MantenimientoTipo.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 w ww. ja v a2 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 + " el Tipo?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { tipoControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase()); tipoControlador.accion(accion); lista.add(tipoControlador.getSeleccionado()); if (accion == 1) { JOptionPane.showMessageDialog(null, "Tipo " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); FormularioUtil.limpiarComponente(panelDatos); } else { JOptionPane.showMessageDialog(null, "Tipo no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { FormularioUtil.limpiarComponente(panelDatos); JOptionPane.showMessageDialog(null, "Tipo no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else if (accion == 2) { palabra = "modificar"; palabra2 = "modificado"; if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Tipo?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { if (accion == 2) { JOptionPane.showMessageDialog(null, "Tipo " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); lista.clear(); tipoControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase()); tipoControlador.accion(accion); listar(); FormularioUtil.limpiarComponente(panelDatos); } else { JOptionPane.showMessageDialog(null, "Tipo no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { FormularioUtil.limpiarComponente(panelDatos); JOptionPane.showMessageDialog(null, "Tipo no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } FormularioUtil.limpiarComponente(panelDatos); FormularioUtil.activarComponente(panelOpciones, true); FormularioUtil.activarComponente(panelGuardar, false); FormularioUtil.activarComponente(panelDatos, false); } }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.AngleDirectController.java
/** * @param pdfFile/*from w w w .j a v a 2s .com*/ */ private void tryToCreateFile(File pdfFile, JFreeChart chart) { try { boolean success = pdfFile.createNewFile(); if (success) { singleCellPreProcessingController.showMessage("Chart saved to file!", "chart saved OK", JOptionPane.INFORMATION_MESSAGE); } else { Object[] options = { "Yes", "No", "Cancel" }; int showOptionDialog = JOptionPane.showOptionDialog(null, "File already exists. Do you want to replace it?", "", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[2]); // if YES, user wants to delete existing file and replace it if (showOptionDialog == 0) { boolean delete = pdfFile.delete(); if (!delete) { return; } // if NO, returns already existing file } else if (showOptionDialog == 1) { return; } } } catch (IOException ex) { singleCellPreProcessingController.showMessage("Unexpected error: " + ex.getMessage() + ".", "Unexpected error", JOptionPane.ERROR_MESSAGE); return; } try (FileOutputStream fileOutputStream = new FileOutputStream(pdfFile)) { // actually create PDF file createPdfFile(fileOutputStream, chart); } catch (IOException ex) { singleCellPreProcessingController.showMessage("Unexpected error: " + ex.getMessage() + ".", "Unexpected error", JOptionPane.ERROR_MESSAGE); } }
From source file:serial.ChartFromSerial.java
private void pause_jBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pause_jBtnActionPerformed if ("Play".equals(pause_jBtn.getText())) { while (!chosenPort.openPort()) { if (JOptionPane.showConfirmDialog(rootPane, "Error at " + portList_jCombo.getSelectedItem().toString() + "\nWould you like to refresh?", "Trouble connecting to " + portList_jCombo.getSelectedItem().toString(), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE) == JOptionPane.NO_OPTION) { buttonsOff();/* www. ja va 2 s. c o m*/ return; } else { portNames = SerialPort.getCommPorts(); if (portNames.length > 0) { if (portNames.length >= 1) { Object[] possibilities = new Object[portNames.length]; for (int i = 0; i < portNames.length; i++) { possibilities[i] = portNames[i].getSystemPortName(); } String s = (String) JOptionPane.showInputDialog(rootPane, "Other ports are available.\nSelect one to continue on that port or cancel to disconnect.", "Another port is available", JOptionPane.PLAIN_MESSAGE, null, possibilities, null); chosenPort.closePort(); if (s != null) { chosenPort = SerialPort.getCommPort(s); chosenPort.setComPortTimeouts(SerialPort.TIMEOUT_SCANNER, 0, 0); chosenPort.setBaudRate( Integer.parseInt(baudRate_jCombo.getSelectedItem().toString())); softRefresh(); portList_jCombo.setSelectedItem(s); if (chosenPort.openPort()) { createSerialThread(chosenPort); pause_jBtn.setText("Pause"); connect_jBtn.setEnabled(true); return; } } else { buttonsOff(); return; } } else { if (JOptionPane.showConfirmDialog(rootPane, portNames[0].getSystemPortName() + " is available. Would you like to use it instead?", "Another port is available", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { chosenPort.closePort(); chosenPort = SerialPort.getCommPort(portNames[0].getSystemPortName()); chosenPort.setComPortTimeouts(SerialPort.TIMEOUT_SCANNER, 0, 0); chosenPort.setBaudRate( Integer.parseInt(baudRate_jCombo.getSelectedItem().toString())); softRefresh(); portList_jCombo.setSelectedItem(portNames[0].getSystemPortName()); if (chosenPort.openPort()) { createSerialThread(chosenPort); pause_jBtn.setText("Pause"); connect_jBtn.setEnabled(true); return; } } else { buttonsOff(); return; } } } else { JOptionPane.showMessageDialog(rootPane, "You are currently not connected to any devices.", "No devices found", JOptionPane.INFORMATION_MESSAGE); softRefresh(); buttonsOff(); return; } } } createSerialThread(chosenPort); pause_jBtn.setText("Pause"); } else { chosenPort.closePort(); pause_jBtn.setText("Play"); } }