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:gdt.jgui.entity.edge.JBondsPanel.java
/** * Get the context menu.//from w w w . ja va 2 s. co m * @return the context menu. */ @Override public JMenu getContextMenu() { menu = super.getContextMenu(); int cnt = menu.getItemCount(); mia = new JMenuItem[cnt]; for (int i = 0; i < cnt; i++) mia[i] = menu.getItem(i); menu.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { //System.out.println("WeblinkPanel:getConextMenu:menu selected"); menu.removeAll(); if (mia != null) { for (JMenuItem mi : mia) menu.add(mi); menu.addSeparator(); } if (hasSelectedItems()) { JMenuItem deleteItem = new JMenuItem("Delete"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { String[] sa = JBondsPanel.this.listSelectedItems(); if (sa == null) return; for (String s : sa) { // System.out.println("JBondsPanel:delete:s="+s); if (isGraphEntity()) removeBondEntry(s); else if (isEdgeEntity()) removeBond(console, s); else if (isDetailEntity()) { System.out.println("JBondsPanel:delete detail:"); Entigrator entigrator = console.getEntigrator(entihome$); BondDetailHandler.deleteDetail(entigrator, s); } } close(); JBondsPanel bp = new JBondsPanel(); String bpLocator$ = bp.getLocator(); bpLocator$ = Locator.append(bpLocator$, Entigrator.ENTIHOME, entihome$); bpLocator$ = Locator.append(bpLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, bpLocator$); } } }); menu.add(deleteItem); JMenuItem copyItem = new JMenuItem("Copy"); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String[] sa = JBondsPanel.this.listSelectedItems(); if (sa == null) return; for (String s : sa) { console.clipboard.putString(s); } } }); menu.add(copyItem); menu.addSeparator(); } if (isEdgeEntity()) { JMenuItem newItem = new JMenuItem("New"); newItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //System.out.println("JBondsPanel:new:"+locator$); Entigrator entigrator = console.getEntigrator(entihome$); Sack entity = entigrator.getEntityAtKey(entityKey$); if (!entity.existsElement("bond")) entity.createElement("bond"); String bondKey$ = Identity.key(); entity.putElementItem("bond", new Core(null, bondKey$, null)); // String icon$=Support.readHandlerIcon(JEntitiesPanel.class, "globe.png"); entigrator.save(entity); // JBondsPanel.this.getPanel().removeAll(); close(); JBondsPanel bp = new JBondsPanel(); String bpLocator$ = bp.getLocator(); bpLocator$ = Locator.append(bpLocator$, Entigrator.ENTIHOME, entihome$); bpLocator$ = Locator.append(bpLocator$, EntityHandler.ENTITY_KEY, entityKey$); //bpLocator$=Locator.append(bpLocator$, BaseHandler.HANDLER_METHOD,"instantiate"); JConsoleHandler.execute(console, bpLocator$); } }); menu.add(newItem); } if (isGraphEntity()) { JMenuItem showItem = new JMenuItem("Show"); showItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { JGraphRenderer gr = new JGraphRenderer(); String grLocator$ = gr.getLocator(); grLocator$ = Locator.append(grLocator$, Entigrator.ENTIHOME, entihome$); grLocator$ = Locator.append(grLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, grLocator$); } catch (Exception ee) { Logger.getLogger(JGraphRenderer.class.getName()).info(ee.toString()); } } }); menu.add(showItem); if (hasBondsToPaste()) { JMenuItem pasteItem = new JMenuItem("Paste"); pasteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { pasteBonds(); JBondsPanel bp = new JBondsPanel(); String bpLocator$ = bp.getLocator(); bpLocator$ = Locator.append(bpLocator$, Entigrator.ENTIHOME, entihome$); bpLocator$ = Locator.append(bpLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, bpLocator$); } }); menu.add(pasteItem); } } JMenuItem doneItem = new JMenuItem("Done"); doneItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (requesterResponseLocator$ != null) { try { byte[] ba = Base64.decodeBase64(requesterResponseLocator$); String responseLocator$ = new String(ba, "UTF-8"); JConsoleHandler.execute(console, responseLocator$); } catch (Exception ee) { Logger.getLogger(JBondsPanel.class.getName()).severe(ee.toString()); } } else console.back(); } }); menu.add(doneItem); menu.addSeparator(); JMenuItem sortInNode = new JMenuItem("Sort in node"); sortInNode.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { selectMode$ = SELECT_MODE_IN; JItemPanel[] ipa = getItems(); Entigrator entigrator = console.getEntigrator(entihome$); InNodeComparator inc = new InNodeComparator(); inc.entigrator = entigrator; ArrayList<JItemPanel> ipl = new ArrayList<JItemPanel>(Arrays.asList(ipa)); Collections.sort(ipl, inc); panel.removeAll(); // System.out.println("JBondsPanel:sort in node:ipl="+ipl.size()); if (ipa != null) for (JItemPanel ip : ipl) { panel.add(ip); } revalidate(); repaint(); Sack entity = entigrator.getEntityAtKey(entityKey$); if (!entity.existsElement("parameter")) entity.createElement("parameter"); entity.putElementItem("parameter", new Core(null, SELECT_MODE, selectMode$)); entigrator.save(entity); } catch (Exception ee) { } } }); menu.add(sortInNode); JMenuItem sortOutNode = new JMenuItem("Sort out node"); sortOutNode.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { selectMode$ = SELECT_MODE_OUT; JItemPanel[] ipa = getItems(); ArrayList<JItemPanel> ipl = new ArrayList<JItemPanel>(Arrays.asList(ipa)); Collections.sort(ipl, new ItemPanelComparator()); panel.removeAll(); System.out.println("JBondsPanel:sort out node:ipl=" + ipl.size()); if (ipa != null) for (JItemPanel ip : ipl) { panel.add(ip); } revalidate(); repaint(); Entigrator entigrator = console.getEntigrator(entihome$); Sack entity = entigrator.getEntityAtKey(entityKey$); if (!entity.existsElement("parameter")) entity.createElement("parameter"); entity.putElementItem("parameter", new Core(null, SELECT_MODE, selectMode$)); entigrator.save(entity); } catch (Exception ee) { } } }); menu.add(sortOutNode); } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); return menu; }
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;/* w w w .j a v 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:lu.fisch.unimozer.Diagram.java
public void doAutoSave() { //if (saveTimer.isRunning()) saveTimer.stop(); if (hasChangedAutoSave == true) { // has the project allready been saved once? //if(directoryName==null) //{//from w ww.java2 s. c o m // no, so ask to save it right now //custom title, warning icon Object[] options = { "Yes", "No" }; int n = JOptionPane.showOptionDialog(frame, "You didn't save your project yet!\n" + "Do you want to save it right now?", "Auto save", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (n == 0) { this.saveUnimozer(); hasChangedAutoSave = false; } //} /* else { // yes, so go ahead an create a backup createBackup(); hasChangedAutoSave=false; } saveTimer.start(); */ } else if (hasChanged) { Object[] options = { "Yes", "No" }; int n = JOptionPane.showOptionDialog(frame, "You didn't save your project for at least 10 minutes!\n" + "Do you want to save it right now?", "Auto save", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (n == 0) { this.saveUnimozer(); } } }
From source file:com.opendoorlogistics.studio.scripts.editor.ScriptEditor.java
public void disposeWithSavePrompt() { String currentXML = getXML(); if (currentXML.equals(lastOutputXML) == false) { if (JOptionPane.showConfirmDialog(ScriptEditor.this, "Script has been modified but not saved, changes will be lost. Really close?", "Really Closing?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { ScriptEditor.this.dispose(); }//from ww w .ja v a2s . c om } else { ScriptEditor.this.dispose(); } }
From source file:com.sec.ose.osi.ui.frm.main.report.JPanExportReport.java
private JButton getJButtonOK() { if (jButtonOK == null) { jButtonOK = new JButton(); jButtonOK.setText(" OK "); jButtonOK.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { String dirPath = jTextFieldReportLocation.getText(); File dir = new File(dirPath); if (dir.exists() == false) { int choice = JOptionPane.showOptionDialog(null, "\"" + dir + "\" is not existed folder. Do you want to create it now?", "Alarm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (choice == JOptionPane.NO_OPTION) { return; }// www . j ava 2s . co m dir.mkdirs(); } if (getJRadioButtonIdentify().isSelected()) { mEventHandler.handle(EventHandler.BTN_OK_IDENTIFY); } else if (getJRadioButtonSPDX().isSelected()) { mEventHandler.handle(EventHandler.BTN_OK_SPDX); } else if (getJRadioButtonBoth().isSelected()) { mEventHandler.handle(EventHandler.BTN_OK_BOTH); } } }); } return jButtonOK; }
From source file:com.xmage.launcher.XMageLauncher.java
@Override public void run() { frame.setVisible(true);//from w w w . ja v a 2s.co m 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 {//from ww w .j a v a 2 s . c om 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: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); }/* ww w. j a v a 2 s . c o m*/ } 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 va 2s.co m * * @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); }/*w w w . ja v a2s . 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); } }