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: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 www . j a va2 s. co 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:at.becast.youploader.gui.FrmMain.java
protected void startUploads() { UploadMgr.setSpeed_limit(speed);//w ww.ja v a 2 s .co m if ("0".equals(Main.s.setting.get("tos_agreed")) && !this.tos) { if (Main.debug) LOG.debug("Asking about ToS Agreement"); //Dummy JFrame to keep Dialog on top JFrame frmOpt = new JFrame(); frmOpt.setAlwaysOnTop(true); JCheckBox checkbox = new JCheckBox(LANG.getString("frmMain.tos.Remember")); String message = LANG.getString("frmMain.tos.Message"); Object[] params = { message, checkbox }; int n; do { n = JOptionPane.showConfirmDialog(frmOpt, params, LANG.getString("frmMain.tos.Title"), JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE); } while (n == JOptionPane.CLOSED_OPTION); if (n == JOptionPane.OK_OPTION) { if (Main.debug) LOG.debug("Agreed to ToS"); if (checkbox.isSelected()) { Main.s.setting.put("tos_agreed", "1"); Main.s.save("tos_agreed"); } this.tos = true; UploadMgr.start(); } frmOpt.dispose(); } else { if (Main.debug) LOG.debug("Previously agreed to ToS"); UploadMgr.start(); } }
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 w w . jav a 2 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: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 w w . j a v a2 s . c o 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); }
From source file:ca.uhn.hl7v2.testpanel.controller.Controller.java
private int showPromptToSaveMessageBeforeClosingIt(Hl7V2MessageCollection theMsg, boolean theShowCancelButton) { Component parentComponent = myView.getFrame(); Object message = "<html>The following file is unsaved, do you want to save before closing?<br>" + theMsg.getBestDescription() + "</html>"; String title = DIALOG_TITLE;//from w w w.j a v a2 s.c o m int optionType = theShowCancelButton ? JOptionPane.YES_NO_CANCEL_OPTION : JOptionPane.YES_NO_OPTION; int messageType = JOptionPane.QUESTION_MESSAGE; return JOptionPane.showConfirmDialog(parentComponent, message, title, optionType, messageType); }
From source file:com.mirth.connect.connectors.file.FileWriter.java
private void schemeComboBoxActionPerformed(ActionEvent evt) { String text = (String) schemeComboBox.getSelectedItem(); if (!text.equals(selectedScheme)) { if (StringUtils.isNotEmpty(selectedScheme) && !isAdvancedDefault()) { if (JOptionPane.showConfirmDialog(parent, "Are you sure you would like to change the scheme mode and lose all of the current properties?", "Select an Option", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) { schemeComboBox.setSelectedItem(selectedScheme); return; }//ww w . j a v a2 s .co m } // if File is selected if (text.equals(FileScheme.FILE.getDisplayName())) { onSchemeChange(false, true, true, FileScheme.FILE); } // else if FTP is selected else if (text.equals(FileScheme.FTP.getDisplayName())) { onSchemeChange(true, anonymousYesRadio.isSelected(), true, FileScheme.FTP); hostLabel.setText("ftp://"); } // else if SFTP is selected else if (text.equals(FileScheme.SFTP.getDisplayName())) { onSchemeChange(true, false, true, FileScheme.SFTP); hostLabel.setText("sftp://"); } // else if SMB is selected else if (text.equals(FileScheme.SMB.getDisplayName())) { onSchemeChange(true, false, true, FileScheme.SMB); hostLabel.setText("smb://"); } // else if WEBDAV is selected else if (text.equals(FileScheme.WEBDAV.getDisplayName())) { onSchemeChange(true, anonymousYesRadio.isSelected(), false, FileScheme.WEBDAV); if (secureModeYesRadio.isSelected()) { hostLabel.setText("https://"); } else { hostLabel.setText("http://"); } } decorateConnectorType(); } selectedScheme = text; }
From source file:com.sshtools.sshterm.SshTerminalPanel.java
private boolean performVerifiedDisconnect(boolean force) { // Lets examine the profile to see if we need to close the connection SshToolsConnectionProfile profile = getCurrentConnectionProfile(); if (profile.disconnectOnSessionClose()) { // Yes we should, lets ask the user about any forwarding channels if (ssh.getForwardingClient().hasActiveConfigurations()) { return (JOptionPane.showConfirmDialog(SshTerminalPanel.this, "There are currently active forwarding channels!\n\n" + "The profile is configured to disconnect when the session is closed. Closing\n" + "the connection will terminate these forwarding channels with unexpected results.\n\n" + "Do you want to disconnect now?", "Auto disconnect", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION); } else {// www . j a v a 2 s .co m return true; } } return force; }
From source file:com.proyecto.vista.MantenimientoBien.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = Controlador.ELIMINAR;//from w w w .jav a 2s . co m 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); } 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:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java
public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equalsIgnoreCase("Rename ...")) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); QueryMasterData ndata = (QueryMasterData) node.getUserObject(); Object inputValue = JOptionPane.showInputDialog(this, "Rename this query to: ", "Rename Query Dialog", JOptionPane.PLAIN_MESSAGE, null, null, ndata.name().substring(0, ndata.name().lastIndexOf("[") - 1)); if (inputValue != null) { String newQueryName = (String) inputValue; String requestXml = ndata.writeRenameQueryXML(newQueryName); lastRequestMessage = requestXml; setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = QueryListNamesClient.sendQueryRequestREST(requestXml); if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); }/*from ww w . j a v a 2 s . com*/ }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } lastResponseMessage = response; if (response != null) { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); if (status.equalsIgnoreCase("DONE")) { ndata.name(newQueryName + " [" + ndata.userId() + "]"); node.setUserObject(ndata); //DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); jTree1.repaint(); } } catch (Exception ex) { ex.printStackTrace(); } } setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } else if (e.getActionCommand().equalsIgnoreCase("Delete")) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent(); QueryMasterData ndata = (QueryMasterData) node.getUserObject(); Object selectedValue = JOptionPane.showConfirmDialog(this, "Delete Query \"" + ndata.name() + "\"?", "Delete Query Dialog", JOptionPane.YES_NO_OPTION); if (selectedValue.equals(JOptionPane.YES_OPTION)) { System.out.println("delete " + ndata.name()); String requestXml = ndata.writeDeleteQueryXML(); lastRequestMessage = requestXml; //System.out.println(requestXml); setCursor(new Cursor(Cursor.WAIT_CURSOR)); String response = QueryListNamesClient.sendQueryRequestREST(requestXml); if (response.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return; } lastResponseMessage = response; if (response != null) { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); try { JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus(); String status = statusType.getType(); if (status.equalsIgnoreCase("DONE")) { treeModel.removeNodeFromParent(node); //jTree1.repaint(); } } catch (Exception ex) { ex.printStackTrace(); } } setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } else if (e.getActionCommand().equalsIgnoreCase("Refresh All")) { String status = loadPreviousQueries(false); if (status.equalsIgnoreCase("")) { reset(200, false); } else if (status.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); } } }
From source file:AppSpringLayout.java
protected void saveFileChooser(String fileUrl) { fc.setDialogTitle("Specify name of the file to save"); File output = new File(fc.getSelectedFile().toString()); // check if file already exists, ask user if they wish to overwrite it if (output.exists()) { int response = JOptionPane.showConfirmDialog(null, // "Do you want to replace the existing file?", // "Confirm", JOptionPane.YES_NO_OPTION, // JOptionPane.QUESTION_MESSAGE); if (response != JOptionPane.YES_OPTION) { return; }/*from w ww . j a va2s .co m*/ } fc.setSelectedFile(output); try { URL fileNameAsUrl = new URL(fileUrl); originalImage = ImageIO.read(fileNameAsUrl); ImageIO.write(toBufferedImage(originalImage), "jpeg", output); System.out.println("image saved, in the folder: " + output.getAbsolutePath()); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }