List of usage examples for javax.swing JOptionPane OK_CANCEL_OPTION
int OK_CANCEL_OPTION
To view the source code for javax.swing JOptionPane OK_CANCEL_OPTION.
Click Source Link
showConfirmDialog
. From source file:br.com.atmatech.sac.view.ViewListaAtendimento.java
private void jBexcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBexcluirActionPerformed // TODO add your handling code here: if (jTatendimento.getSelectedRow() >= 0) { if ((Integer) jTatendimento.getValueAt(jTatendimento.getSelectedRow(), 0) > 0) { if (JOptionPane.showConfirmDialog(this, "Deseja Excluir o Atendimento: " + jTatendimento.getValueAt(jTatendimento.getSelectedRow(), 0), "Atendimento", JOptionPane.OK_CANCEL_OPTION) == 0) { deleteAtendimento();//from w ww. j a v a 2 s. co m } } else { JOptionPane.showMessageDialog(this, "Selecione um Registro Para Excluir", "Atendimento", JOptionPane.INFORMATION_MESSAGE); } } }
From source file:be.agiv.security.demo.Main.java
private void ipStsIssueToken() { GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints gridBagConstraints = new GridBagConstraints(); JPanel contentPanel = new JPanel(gridBagLayout); JLabel urlLabel = new JLabel("URL:"); gridBagConstraints.gridx = 0;/*from w w w . j a va 2 s . c om*/ gridBagConstraints.gridy = 0; gridBagConstraints.anchor = GridBagConstraints.WEST; gridBagConstraints.ipadx = 5; gridBagLayout.setConstraints(urlLabel, gridBagConstraints); contentPanel.add(urlLabel); JTextField urlTextField = new JTextField( "https://auth.beta.agiv.be/ipsts/Services/DaliSecurityTokenServiceConfiguration.svc/IWSTrust13", 60); gridBagConstraints.gridx++; gridBagLayout.setConstraints(urlTextField, gridBagConstraints); contentPanel.add(urlTextField); JLabel realmLabel = new JLabel("Realm:"); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagLayout.setConstraints(realmLabel, gridBagConstraints); contentPanel.add(realmLabel); JTextField realmTextField = new JTextField(AGIVSecurity.BETA_REALM, 30); gridBagConstraints.gridx++; gridBagLayout.setConstraints(realmTextField, gridBagConstraints); contentPanel.add(realmTextField); CredentialPanel credentialPanel = new CredentialPanel(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(credentialPanel, gridBagConstraints); contentPanel.add(credentialPanel); int result = JOptionPane.showConfirmDialog(this, contentPanel, "IP-STS Issue Token", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.CANCEL_OPTION) { return; } String location = urlTextField.getText(); String username = credentialPanel.getUsername(); String password = credentialPanel.getPassword(); File pkcs12File = credentialPanel.getPKCS12File(); String realm = realmTextField.getText(); IPSTSClient ipStsClient = new IPSTSClient(location, realm); try { if (null != username) { this.ipStsSecurityToken = ipStsClient.getSecurityToken(username, password); } else { KeyStore keyStore = KeyStore.getInstance("PKCS12"); keyStore.load(new FileInputStream(pkcs12File), password.toCharArray()); String alias = keyStore.aliases().nextElement(); X509Certificate certificate = (X509Certificate) keyStore.getCertificate(alias); PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, password.toCharArray()); this.ipStsSecurityToken = ipStsClient.getSecuritytoken(certificate, privateKey); } this.ipStsViewMenuItem.setEnabled(true); this.rStsIssueMenuItem.setEnabled(true); ipStsViewToken(); } catch (Exception e) { showException(e); } }
From source file:fi.hoski.remote.ui.Admin.java
private JMenuItem menuItemRestoreEntity() { final String title = TextUtil.getText("RESTORE ENTITY"); JMenuItem backupYearItem = new JMenuItem(title); ActionListener backupYearAction = new ActionListener() { @Override/* w w w .j a va2s.c o m*/ public void actionPerformed(ActionEvent e) { Object kind = JOptionPane.showInputDialog(frame, title, "", JOptionPane.OK_CANCEL_OPTION, null, serverProperties.getTables(), null); if (kind != null) { File file = openFile(BACKUPDIR, ".ser", "Backup"); if (file != null) { int count; try (FileInputStream fos = new FileInputStream(file)) { BufferedInputStream bis = new BufferedInputStream(fos); ObjectInputStream ois = new ObjectInputStream(bis); List<String> list = new ArrayList<String>(); list.add(kind.toString()); count = dss.restore(list, ois); JOptionPane.showMessageDialog(frame, TextUtil.getText("RESTORED") + " " + count); } catch (IOException ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(frame, ex.getMessage()); } } } } }; backupYearAction = createActionListener(frame, backupYearAction); backupYearItem.addActionListener(backupYearAction); return backupYearItem; }
From source file:pi.bestdeal.gui.InterfacePrincipale.java
private void Delete_ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Delete_ButtonActionPerformed int result = JOptionPane.showConfirmDialog(null, "Voulez Vous Supprimer" + " ( " + (String) jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 1) + " ) ", null, JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { int idd = (int) jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 0); DealDAO dealdao = DealDAO.getInstance(); int a = dealdao.deleteDeal(idd); if (a == 1) { JOptionPane.showMessageDialog(null, "Deal Supprim"); DealTableModel mymodel = new DealTableModel(list.displayDeal()); jTable1.setModel(mymodel);/*from www . j a v a 2s. c o m*/ jTable1.removeColumn(jTable1.getColumn("ID")); jTable1.removeColumn(jTable1.getColumn("Description")); jTable1.removeColumn(jTable1.getColumn("Achat Actuel")); jTable1.removeColumn(jTable1.getColumn("Etat")); jTable1.removeColumn(jTable1.getColumn("Statut")); jTable1.removeColumn(jTable1.getColumn("Nombre d'Affichage")); jTable1.removeColumn(jTable1.getColumn("Vendeur")); jTable1.getColumnModel().setColumnMargin(20); if (!list.displayDeal().isEmpty()) { jTable1.setRowSelectionInterval(0, 0); } } } }
From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_node.java
private List<JComponent> getExtraOptions(final int row, final Object itemId) { List<JComponent> options = new LinkedList<JComponent>(); final int numRows = model.getRowCount(); final List<Node> tableVisibleNodes = getVisibleElementsInTable(); if (itemId != null) { JMenuItem switchCoordinates_thisNode = new JMenuItem("Switch node coordinates from (x,y) to (y,x)"); switchCoordinates_thisNode.addActionListener(new ActionListener() { @Override/* w w w. j a va2 s.co m*/ public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); Node node = netPlan.getNodeFromId((long) itemId); Point2D currentPosition = node.getXYPositionMap(); node.setXYPositionMap(new Point2D.Double(currentPosition.getY(), currentPosition.getX())); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.NODE)); callback.runCanvasOperation(ITopologyCanvas.CanvasOperation.ZOOM_ALL); callback.getUndoRedoNavigationManager().addNetPlanChange(); } }); options.add(switchCoordinates_thisNode); JMenuItem xyPositionFromAttributes_thisNode = new JMenuItem("Set node coordinates from attributes"); xyPositionFromAttributes_thisNode.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); Set<String> attributeSet = new LinkedHashSet<String>(); Node node = netPlan.getNodeFromId((long) itemId); attributeSet.addAll(node.getAttributes().keySet()); try { if (attributeSet.isEmpty()) throw new Exception("No attribute to select"); final JComboBox latSelector = new WiderJComboBox(); final JComboBox lonSelector = new WiderJComboBox(); for (String attribute : attributeSet) { latSelector.addItem(attribute); lonSelector.addItem(attribute); } JPanel pane = new JPanel(new MigLayout("", "[][grow]", "[][]")); pane.add(new JLabel("X-coordinate / Longitude: ")); pane.add(lonSelector, "growx, wrap"); pane.add(new JLabel("Y-coordinate / Latitude: ")); pane.add(latSelector, "growx, wrap"); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please select the attributes for coordinates", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { String latAttribute = latSelector.getSelectedItem().toString(); String lonAttribute = lonSelector.getSelectedItem().toString(); node.setXYPositionMap( new Point2D.Double(Double.parseDouble(node.getAttribute(lonAttribute)), Double.parseDouble(node.getAttribute(latAttribute)))); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.NODE)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error retrieving coordinates from attributes"); break; } } callback.runCanvasOperation(ITopologyCanvas.CanvasOperation.ZOOM_ALL); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error retrieving coordinates from attributes"); } } }); options.add(xyPositionFromAttributes_thisNode); JMenuItem nameFromAttribute_thisNode = new JMenuItem("Set node name from attribute"); nameFromAttribute_thisNode.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); Set<String> attributeSet = new LinkedHashSet<String>(); long nodeId = (long) itemId; attributeSet.addAll(netPlan.getNodeFromId(nodeId).getAttributes().keySet()); try { if (attributeSet.isEmpty()) throw new Exception("No attribute to select"); final JComboBox selector = new WiderJComboBox(); for (String attribute : attributeSet) selector.addItem(attribute); JPanel pane = new JPanel(new MigLayout("", "[][grow]", "[]")); pane.add(new JLabel("Name: ")); pane.add(selector, "growx, wrap"); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please select the attribute for name", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { String name = selector.getSelectedItem().toString(); netPlan.getNodeFromId(nodeId) .setName(netPlan.getNodeFromId(nodeId).getAttribute(name)); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.NODE)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error retrieving name from attribute"); break; } } } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error retrieving name from attribute"); } } }); options.add(nameFromAttribute_thisNode); } if (numRows > 1) { if (!options.isEmpty()) options.add(new JPopupMenu.Separator()); JMenuItem switchCoordinates_allNodes = new JMenuItem( "Switch all table node coordinates from (x,y) to (y,x)"); switchCoordinates_allNodes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (Node n : tableVisibleNodes) { Point2D currentPosition = n.getXYPositionMap(); double newX = currentPosition.getY(); double newY = currentPosition.getX(); Point2D newPosition = new Point2D.Double(newX, newY); n.setXYPositionMap(newPosition); } callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.NODE)); callback.runCanvasOperation(ITopologyCanvas.CanvasOperation.ZOOM_ALL); callback.getUndoRedoNavigationManager().addNetPlanChange(); } }); options.add(switchCoordinates_allNodes); JMenuItem xyPositionFromAttributes_allNodes = new JMenuItem( "Set all table node coordinates from attributes"); xyPositionFromAttributes_allNodes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Set<String> attributeSet = new LinkedHashSet<String>(); for (Node node : tableVisibleNodes) attributeSet.addAll(node.getAttributes().keySet()); try { if (attributeSet.isEmpty()) throw new Exception("No attribute to select"); final JComboBox latSelector = new WiderJComboBox(); final JComboBox lonSelector = new WiderJComboBox(); for (String attribute : attributeSet) { latSelector.addItem(attribute); lonSelector.addItem(attribute); } JPanel pane = new JPanel(new MigLayout("", "[][grow]", "[][]")); pane.add(new JLabel("X-coordinate / Longitude: ")); pane.add(lonSelector, "growx, wrap"); pane.add(new JLabel("Y-coordinate / Latitude: ")); pane.add(latSelector, "growx, wrap"); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please select the attributes for coordinates", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { String latAttribute = latSelector.getSelectedItem().toString(); String lonAttribute = lonSelector.getSelectedItem().toString(); for (Node node : tableVisibleNodes) node.setXYPositionMap( new Point2D.Double(Double.parseDouble(node.getAttribute(lonAttribute)), Double.parseDouble(node.getAttribute(latAttribute)))); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.NODE)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error retrieving coordinates from attributes"); break; } } callback.runCanvasOperation(ITopologyCanvas.CanvasOperation.ZOOM_ALL); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error retrieving coordinates from attributes"); } } }); options.add(xyPositionFromAttributes_allNodes); JMenuItem nameFromAttribute_allNodes = new JMenuItem("Set all table node names from attribute"); nameFromAttribute_allNodes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Set<String> attributeSet = new LinkedHashSet<String>(); for (Node node : tableVisibleNodes) attributeSet.addAll(node.getAttributes().keySet()); try { if (attributeSet.isEmpty()) throw new Exception("No attribute to select"); final JComboBox selector = new WiderJComboBox(); for (String attribute : attributeSet) selector.addItem(attribute); JPanel pane = new JPanel(new MigLayout("", "[][grow]", "[]")); pane.add(new JLabel("Name: ")); pane.add(selector, "growx, wrap"); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please select the attribute for name", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { String name = selector.getSelectedItem().toString(); for (Node node : tableVisibleNodes) node.setName(node.getAttribute(name) != null ? node.getAttribute(name) : ""); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.NODE)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error retrieving name from attribute"); break; } } } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error retrieving name from attribute"); } } }); options.add(nameFromAttribute_allNodes); } return options; }
From source file:org.adamkrajcik.gui.MainForm.java
private void createWineMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createWineMenuItemActionPerformed JTextField name = new JTextField(); SpinnerNumberModel model = new SpinnerNumberModel((short) Calendar.getInstance().get(Calendar.YEAR), (short) 1700, (short) Calendar.getInstance().get(Calendar.YEAR), (short) 1); JSpinner vintage = new JSpinner(model); SpinnerNumberModel model2 = new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1); JSpinner quantity = new JSpinner(model2); String[] wineTypes = { "RED", "WHITE", "ROSE" }; JComboBox type = new JComboBox(wineTypes); List<String> myList = new ArrayList<String>(); for (String countryCode : Locale.getISOCountries()) { Locale obj = new Locale("", countryCode); myList.add(obj.getDisplayCountry(Locale.ENGLISH)); }//from w w w. j a va 2 s . c o m String[] x = new String[myList.size()]; myList.toArray(x); JComboBox countryList = new JComboBox(x); Object[] message = { "Name:", name, "Country:", countryList, "Vintage:", vintage, "Quantity", quantity, "Type", type, }; int option = JOptionPane.showConfirmDialog(null, message, "New Wine", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (option == JOptionPane.OK_OPTION) { if (name.getText().length() == 0) { JOptionPane.showConfirmDialog(null, langResource.getString("errorName"), langResource.getString("errorName"), JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); createWineMenuItemActionPerformed(null); return; } new CreateWineSwingWorker(newWine(name.getText(), (String) countryList.getSelectedItem(), (short) ((int) vintage.getValue()), (int) quantity.getValue(), WineType.valueOf((String) type.getSelectedItem()))).execute(); } }
From source file:pi.bestdeal.gui.InterfacePrincipale.java
private void ReplyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReplyButtonActionPerformed Interface_Mail intmail = new Interface_Mail(); intmail.txt_to.setText(jTableMessage.getModel().getValueAt(jTableMessage.getSelectedRow(), 2).toString()); int result = JOptionPane.showConfirmDialog(null, intmail, "Test", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { Mail monmail = new Mail(); if (intmail.txt_cc.getText().equals("")) { monmail.sendEmail(intmail.txt_to.getText(), intmail.txt_to.getText(), intmail.jTextField4.getText(), intmail.txa_content.getText()); } else {//from w w w . ja v a 2s . c o m monmail.sendEmail(intmail.txt_to.getText(), intmail.txt_cc.getText(), intmail.jTextField4.getText(), intmail.txa_content.getText()); } } }
From source file:org.adamkrajcik.gui.MainForm.java
private void deleteWineMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteWineMenuItemActionPerformed if (WineTable.getSelectedRow() == -1) { JOptionPane.showConfirmDialog(null, langResource.getString("notSelectedWineMessage"), langResource.getString("error"), JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); return;//from w w w .j av a2s. c o m } Wine wineToDelete = wineTableModel.getWineAtRow(WineTable.getSelectedRow()); Object[] message = { langResource.getString("deleteWineMessage"), wineToDelete.toString() }; int option = JOptionPane.showConfirmDialog(null, message, langResource.getString("deleteWine"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (option == JOptionPane.OK_OPTION) { new DeleteWineSwingWorker((wineToDelete)).execute(); } }
From source file:br.com.postalis.folhapgto.proc.TelaPrincipal.java
private void btnImportarIncorporadasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportarIncorporadasActionPerformed carregarParametros();/*from ww w .ja va 2 s. c o m*/ int confirmacao = JOptionPane.showConfirmDialog(null, "Importar rubricas incorporadas na ECT para a referncia: " + txtMesAno + "?", "Importao de incorporadas", JOptionPane.OK_CANCEL_OPTION); if (confirmacao == JOptionPane.OK_OPTION) { new Thread() { public void run() { try { txtStatusProc .setText("Executando importao de rubricas incorporadas na ECT para a referncia: " + txtMesAno + "..."); btnImportarIncorporadas.setEnabled(false); ExitStatus retorno = new SvcFolhaPgtoImpl().consultarRubricasIncorporadas(usuario, anoMesRef, dtRef); if (retorno.equals(EnumExistStatus.VAZIO.getStatus())) { txtStatusProc .setText("No exitem lanamentos a importar na referncia: " + txtMesAno + "."); Thread.sleep(10000); txtStatusProc.setText(""); } else if (retorno.equals(EnumExistStatus.SUCESSO.getStatus())) { txtStatusProc.setText( "Importao concluida com sucesso para a referncia: " + txtMesAno + "."); Thread.sleep(10000); txtStatusProc.setText(""); } else { throw new Exception("O tipo de resultado no esperado: " + retorno.getExitCode()); } } catch (Exception ex) { String msg = "Erro ao executar a importao das rubricas incorporadas para a referncia: " + txtMesAno + ": "; LOGGER.error(msg + ex.getMessage()); txtStatusProc.setText(msg); } finally { btnImportarIncorporadas.setEnabled(true); preencherTabela(); } } }.start(); } }
From source file:frames.consulta.java
private void btneliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btneliminarActionPerformed int filase = tblconsulta.getSelectedRow(); try {//from w ww . j a va 2 s. co m String cedula, nombre, ape, edad, direccion; if (filase == -1) { JOptionPane.showMessageDialog(null, "Debe Seleccionar un Paciente", "Advertencia", JOptionPane.WARNING_MESSAGE); } else { int valor = JOptionPane.showConfirmDialog(this, "Esta Seguro eliminar el paciente?", "Advertencia", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (valor == JOptionPane.YES_NO_OPTION) { JPasswordField pf = new JPasswordField(); int okCxl = JOptionPane.showConfirmDialog(null, pf, "Enter Password", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (okCxl == JOptionPane.OK_OPTION) { String password = new String(pf.getPassword()); String cap = "", cap1 = ""; int id; String encriptado = DigestUtils.md5Hex(password); String sql = ""; sql = "SELECT * FROM administrador WHERE clave='" + encriptado + "'"; try { Statement st = cn.createStatement(); ResultSet rs = st.executeQuery(sql); while (rs.next()) { id = rs.getInt("id_usuario"); cap = rs.getString("usuario"); cap1 = rs.getString("clave"); } if (cap1.equals(encriptado)) { modelo = (DefaultTableModel) tblconsulta.getModel(); cedula = tblconsulta.getValueAt(filase, 0).toString(); nombre = tblconsulta.getValueAt(filase, 1).toString(); ape = tblconsulta.getValueAt(filase, 2).toString(); edad = tblconsulta.getValueAt(filase, 3).toString(); direccion = tblconsulta.getValueAt(filase, 4).toString(); Eliminar(cedula); } else { JOptionPane.showMessageDialog(null, "Clave Invalida", "Advertencia", JOptionPane.WARNING_MESSAGE); } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); ; } //System.err.println("You entered: " + password); } //System.exit(0); } } } catch (Exception e) { //registro.action = "Ver"; } }