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:com.proyecto.vista.MantenimientoTipo.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. j av a 2 s .c o m*/ if (tbltipo.getSelectedRow() != -1) { Integer codigo = tbltipo.getSelectedRow(); Tipo tipo = tipoControlador.buscarPorId(lista.get(codigo).getId()); if (tipo != null) { if (JOptionPane.showConfirmDialog(null, "Desea Eliminar el Tipo?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { int[] filas = tbltipo.getSelectedRows(); for (int i = 0; i < filas.length; i++) { Tipo empleado2 = lista.get(filas[0]); lista.remove(empleado2); tipoControlador.setSeleccionado(empleado2); tipoControlador.accion(accion); } if (tipoControlador.accion(accion) == 3) { JOptionPane.showMessageDialog(null, "Tipo eliminado correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Tipo no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Tipo no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(null, "Debe seleccionar un Tipo", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } }
From source file:jpad.MainEditor.java
private void formWindowClosing(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowClosing {//GEN-HEADEREND:event_formWindowClosing if (!_isOSX) { if (hasChanges) { int dialogResult = JOptionPane.showConfirmDialog(this, "You have unsaved changes, would you like to save these first?", "Question", JOptionPane.YES_NO_CANCEL_OPTION); switch (dialogResult) { case 0: if (hasSavedToFile) saveFile(curFile);// www . j a v a 2s . co m else saveAs(); System.exit(0); break; case 1: System.exit(0); break; case 2: break; } } else { System.exit(0); } } else { if (hasChanges) { int dialogResult = JOptionPane.showConfirmDialog(this, "You have unsaved changes, would you like to save these before you close?", "Question", JOptionPane.YES_NO_CANCEL_OPTION); switch (dialogResult) { case 0: if (hasSavedToFile) saveFile(curFile); else saveAs(); this.setVisible(false); break; case 1: this.setVisible(false); this.dispose(); break; case 2: break; } } } }
From source file:com.xmage.launcher.XMageLauncher.java
@Override public void run() { frame.setVisible(true);/*from w w w . j a v a 2 s. c om*/ frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { if (serverProcess != null) { int response = JOptionPane.showConfirmDialog(frame, messages.getString("serverRunning.message"), messages.getString("serverRunning.title"), JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { Utilities.stopProcess(serverProcess); } } Config.saveProperties(); } }); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (getConfig()) { path = Utilities.getInstallPath(); textArea.append(messages.getString("folder") + path.getAbsolutePath() + "\n"); DownloadLauncherTask launcher = new DownloadLauncherTask(progressBar); launcher.execute(); } } }); }
From source file:com.floreantpos.main.SetUpWindow.java
public void actionPerformed(ActionEvent e) { try {//ww w .j a v a 2s .co m String command = e.getActionCommand(); Database selectedDb = (Database) databaseCombo.getSelectedItem(); final String providerName = selectedDb.getProviderName(); final String databaseURL = tfServerAddress.getText(); final String databasePort = tfServerPort.getText(); final String databaseName = tfDatabaseName.getText(); final String user = tfUserName.getText(); final String pass = new String(tfPassword.getPassword()); final String connectionString = selectedDb.getConnectString(databaseURL, databasePort, databaseName); final String hibernateDialect = selectedDb.getHibernateDialect(); final String driverClass = selectedDb.getHibernateConnectionDriverClass(); if (CANCEL.equalsIgnoreCase(command)) { System.exit(1); return; } setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (TEST.equalsIgnoreCase(command)) { try { DatabaseUtil.checkConnection(connectionString, hibernateDialect, driverClass, user, pass); } catch (DatabaseConnectionException e1) { JOptionPane.showMessageDialog(this, Messages.getString("DatabaseConfigurationDialog.32")); //$NON-NLS-1$ return; } connectionSuccess = true; JOptionPane.showMessageDialog(this, Messages.getString("DatabaseConfigurationDialog.31")); //$NON-NLS-1$ return; } saveConfig(selectedDb, providerName, databaseURL, databasePort, databaseName, user, pass, connectionString, hibernateDialect); if (CREATE_SAMPLE_DATA.equals(command)) { DataImportAction .importMenuItems(DatabaseUtil.class.getResourceAsStream("/floreantpos-menu-items.xml")); //$NON-NLS-1$ } else if (CREATE_DATABASE.equals(command)) { int i = JOptionPane.showConfirmDialog(this, Messages.getString("DatabaseConfigurationDialog.33"), //$NON-NLS-1$ Messages.getString("DatabaseConfigurationDialog.34"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$ if (i != JOptionPane.YES_OPTION) { return; } i = JOptionPane.showConfirmDialog(this, Messages.getString("DatabaseConfigurationDialog.4"), //$NON-NLS-1$ Messages.getString("DatabaseConfigurationDialog.5"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$ boolean generateSampleData = false; if (i == JOptionPane.YES_OPTION) generateSampleData = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); String createDbConnectString = selectedDb.getCreateDbConnectString(databaseURL, databasePort, databaseName); boolean databaseCreated = DatabaseUtil.createDatabase(createDbConnectString, hibernateDialect, driverClass, user, pass, generateSampleData); if (databaseCreated) { JOptionPane.showMessageDialog(SetUpWindow.this, Messages.getString("DatabaseConfigurationDialog.6") + //$NON-NLS-1$ Messages.getString("DatabaseConfigurationDialog.7")); //$NON-NLS-1$ connectionSuccess = true; } else { JOptionPane.showMessageDialog(SetUpWindow.this, Messages.getString("DatabaseConfigurationDialog.36")); //$NON-NLS-1$ } } else if (SAVE.equalsIgnoreCase(command)) { Integer terminalId = tfTerminalNumber.getInteger(); Integer defaultPassLen = tfSecretKeyLength.getInteger(); Integer autoLogOffTime = tfLogoffTime.getInteger(); Boolean isLogOff = chkAutoLogoff.isSelected(); Double scaleFactor = tfScaleFactor.getDouble(); TerminalConfig.setTerminalId(terminalId); TerminalConfig.setDefaultPassLen(defaultPassLen); TerminalConfig.setScreenScaleFactor(scaleFactor); TerminalConfig.setAutoLogoffEnable(isLogOff); TerminalConfig.setAutoLogoffTime(autoLogOffTime <= 0 ? 10 : autoLogOffTime); try { DatabaseUtil.initialize(); saveConfigData(); } catch (Exception ex) { int i = JOptionPane.showConfirmDialog(this, "Connection Failed. Do you want to save?", //$NON-NLS-1$ "Connection status!", JOptionPane.YES_NO_OPTION); //$NON-NLS-1$ if (i == JOptionPane.YES_OPTION) { System.exit(1); } } } } catch (Exception e2) { PosLog.error(getClass(), e2); POSMessageDialog.showMessage(this, e2.getMessage()); } finally { setCursor(Cursor.getDefaultCursor()); } }
From source file:gov.nih.nci.nbia.StandaloneDMDispatcher.java
private void install(String downloadUrl) { Double vNum = 0.0;//from ww w. j a va 2 s . c o m if (appVersion != null) { vNum = Double.parseDouble(appVersion); } String installerPath = getInstallerName(downloadUrl); if (os.contains("windows")) { try { Runtime.getRuntime().exec("msiexec /i \"" + installerPath + "\""); } catch (Exception e) { e.printStackTrace(); } } else if (os.startsWith("mac")) { try { Runtime.getRuntime().exec(new String[] { "/usr/bin/open", installerPath }); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { JLabel pwLabel = new JLabel("Sudo Password"); JTextField password = new JPasswordField(); Object[] objs = { pwLabel, password }; int result = JOptionPane.showConfirmDialog(null, objs, "Please enter a sudo password", JOptionPane.OK_CANCEL_OPTION); String pas = null; if (result == JOptionPane.OK_OPTION) { pas = password.getText(); } if (pas != null) { if (os.equals("CentOS")) { // sudo yum install TCIADownloader-1.0-1.x86_64.rpm try { String upgradCmd = "/usr/bin/sudo -S yum -q -y remove TCIADownloader.x86_64;/usr/bin/sudo -S yum -y -q install "; if (vNum >= 3.2) upgradCmd = "/usr/bin/sudo -S yum -q -y remove NBIADataRetriever.x86_64;/usr/bin/sudo -S yum -y -q install "; String[] cmd = { "/bin/bash", "-c", upgradCmd + installerPath }; Process pb = Runtime.getRuntime().exec(cmd); BufferedWriter writer = null; writer = new BufferedWriter(new OutputStreamWriter(pb.getOutputStream())); writer.write(pas); writer.write('\n'); writer.flush(); String status = null; if (pb.waitFor() == 0) { status = "successfully"; } else { status = "unsuccessfully"; } JOptionPane.showMessageDialog(null, "Installation of new version of NBIA Data Retriever is completed " + status + "."); } catch (IOException | InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else if (os.equals("Ubuntu")) { // sudo dpkg -i tciadownloader_1.0-2_amd64.deb String upgradCmd = "/usr/bin/sudo -S dpkg -i "; if (vNum >= 3.2) upgradCmd = "/usr/bin/sudo -S dpkg -i nbia-data-retriever; /usr/bin/sudo -S dpkg -i "; try { String[] cmd = { "/bin/bash", "-c", upgradCmd + installerPath }; Process pb = Runtime.getRuntime().exec(cmd); BufferedWriter writer = null; writer = new BufferedWriter(new OutputStreamWriter(pb.getOutputStream())); writer.write(pas); writer.write('\n'); writer.flush(); String status = null; if (pb.waitFor() == 0) { status = "successfully"; } else { status = "unsuccessfully"; } JOptionPane.showMessageDialog(null, "Installation of new version of NBIA Data Retriever is completed " + status + "."); } catch (IOException | InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } }
From source file:com.biosis.biosislite.vistas.inventario.MantenimientoClase.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 + " la Clase?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { claseControlador.getSeleccionado().setCodigo(codigoField.getText().toUpperCase()); claseControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase()); claseControlador.accion(accion); lista.add(claseControlador.getSeleccionado()); if (accion == 1) { JOptionPane.showMessageDialog(null, "Clase " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); FormularioUtil.limpiarComponente(panelDatos); } else { JOptionPane.showMessageDialog(null, "Clase no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); }/*from ww w . ja va 2 s . c om*/ } else { FormularioUtil.limpiarComponente(panelDatos); JOptionPane.showMessageDialog(null, "Clase no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else if (accion == 2) { palabra = "modificar"; palabra2 = "modificado"; if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " la Clase?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { if (accion == 2) { JOptionPane.showMessageDialog(null, "Clase " + palabra2 + " correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); lista.clear(); claseControlador.getSeleccionado().setCodigo(codigoField.getText().toUpperCase()); claseControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase()); claseControlador.accion(accion); listar(); FormularioUtil.limpiarComponente(panelDatos); } else { JOptionPane.showMessageDialog(null, "Clase no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { FormularioUtil.limpiarComponente(panelDatos); JOptionPane.showMessageDialog(null, "Clase no " + palabra2, "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } FormularioUtil.activarComponente(panelOpciones, true); FormularioUtil.activarComponente(panelGuardar, false); FormularioUtil.activarComponente(panelDatos, false); }
From source file:jatoo.app.App.java
/** * Displays a YES/NO question.// w w w .j a v a 2 s . c om * * @param question * the question to be displayed * * @return <code>true</code> if YES was selected, <code>false</code> if NO was * selected */ public boolean showQuestion(final String question) { return JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(window, question, getTitle(), JOptionPane.YES_NO_OPTION); }
From source file:com.biosis.biosislite.vistas.inventario.MantenimientoProveedor.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = AbstractControlador.ELIMINAR; if (tblProveedor.getSelectedRow() != -1) { Integer codigo = tblProveedor.getSelectedRow(); Proveedor proveedor = lista.get(codigo); if (proveedor != null) { if (JOptionPane.showConfirmDialog(null, "Desea Eliminar el Proveedor?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { int[] filas = tblProveedor.getSelectedRows(); for (int i = 0; i < filas.length; i++) { Proveedor empleado2 = lista.get(filas[0]); lista.remove(empleado2); proveedorControlador.setSeleccionado(empleado2); proveedorControlador.accion(accion); }/*from ww w .j a v a 2 s . c o m*/ if (proveedorControlador.accion(accion) == 3) { JOptionPane.showMessageDialog(null, "Proveedor eliminado correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Proveedor no eliminado", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Proveedor no eliminado", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(null, "Debe seleccionar un Empleado", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } }
From source file:gui.DownloadPanel.java
public void actionClearAllCompleted() { int action = JOptionPane.showConfirmDialog(parent, "Do you realy want to delete all completed files?", "Confirm delete all", JOptionPane.OK_CANCEL_OPTION); if (action == JOptionPane.OK_OPTION) { List<Download> selectedDownloads = downloadsTableModel.getDownloadsByStatus(DownloadStatus.COMPLETE); clearing = true;//from ww w . ja v a 2 s. c om downloadsTableModel.clearDownloads(selectedDownloads); downloadList.removeAll(selectedDownloads); clearing = false; try { for (Download download : selectedDownloads) { if (selectedDownload == download) selectedDownload = null; DownloadDialog downloadDialog = getDownloadDialogByDownload(download); downloadDialogs.remove(downloadDialog); downloadDialog.removeDownloadInfoListener(this); downloadDialog.dispose(); databaseController.delete(download.getId()); FileUtils.forceDelete(new File( download.getDownloadRangePath() + File.separator + download.getDownloadName())); // todo must again } } catch (SQLException | IOException e) { e.printStackTrace(); } tableSelectionChanged(); } }
From source file:com.proyecto.vista.MantenimientoArea.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed // TODO add your handling code here: accion = Controlador.ELIMINAR;// w w w .ja v a 2 s .c om if (tblarea.getSelectedRow() != -1) { Integer codigo = tblarea.getSelectedRow(); Area area = areaControlador.buscarPorId(lista.get(codigo).getId()); if (area != null) { if (JOptionPane.showConfirmDialog(null, "Desea Eliminar la Area?", "Mensaje del Sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { int[] filas = tblarea.getSelectedRows(); for (int i = 0; i < filas.length; i++) { Area area2 = lista.get(filas[0]); lista.remove(area2); areaControlador.setSeleccionado(area2); areaControlador.accion(accion); } if (areaControlador.accion(accion) == 3) { JOptionPane.showMessageDialog(null, "Area eliminada correctamente", "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Area no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Area no eliminada", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(null, "Debe seleccionar un Area", "Mensaje del Sistema", JOptionPane.ERROR_MESSAGE); } }