List of usage examples for javax.swing JOptionPane OK_OPTION
int OK_OPTION
To view the source code for javax.swing JOptionPane OK_OPTION.
Click Source Link
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 w w w . 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:contactsdirectory.frontend.MainJFrame.java
private void addContact() { final ContactJDialog dialog = new ContactJDialog(this, true); if (JOptionPane.OK_OPTION == dialog.showDialog())//contact != null) {//from ww w . ja v a 2 s .c om Contact contact = dialog.getContact(); Person person = getSelectedPerson(); try { jProgressBar.setIndeterminate(true); jProgressBar.setVisible(true); NewContactSwingWorker worker = new NewContactSwingWorker(contact, person); worker.execute(); ((DefaultListModel<Contact>) jListContact.getModel()).addElement(contact); jProgressBar.setVisible(false); jProgressBar.setIndeterminate(false); } catch (RuntimeException e) { JOptionPane.showMessageDialog(rootPane, localizedTexts.getString("addContactErrMsg"), localizedTexts.getString("errorMsgTitle"), JOptionPane.ERROR_MESSAGE); } } }
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//from ww w . ja v a 2 s . c o 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)); }// w w w .j a v a2s . co 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 .java 2s . c o m*/ monmail.sendEmail(intmail.txt_to.getText(), intmail.txt_cc.getText(), intmail.jTextField4.getText(), intmail.txa_content.getText()); } } }
From source file:at.becast.youploader.gui.FrmMain.java
protected void startUploads() { UploadMgr.setSpeed_limit(speed);/*from ww w . j a v a2 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:contactsdirectory.frontend.MainJFrame.java
private void editContact() { if (jListContact.getSelectedIndex() < 0) { JOptionPane.showMessageDialog(rootPane, localizedTexts.getString("noContactSelected"), "", JOptionPane.INFORMATION_MESSAGE); return;/* w w w . ja va 2s. c om*/ } final ContactJDialog dialog = new ContactJDialog(this, true); dialog.setContact((Contact) jListContact.getSelectedValue());//.getContact()); if (JOptionPane.OK_OPTION == dialog.showDialog())//contact != null) { Contact contact = dialog.getContact(); try { jProgressBar.setIndeterminate(true); jProgressBar.setVisible(true); EditContactSwingWorker worker = new EditContactSwingWorker(contact); worker.execute(); updateContactDetail(); jProgressBar.setVisible(false); jProgressBar.setIndeterminate(false); } catch (RuntimeException e) { JOptionPane.showMessageDialog(this, localizedTexts.getString("editContactErrMsg"), localizedTexts.getString("errorMsgTitle"), JOptionPane.ERROR_MESSAGE); } } }
From source file:edu.ku.brc.specify.config.init.DatabasePanel.java
/** * Check the engine and charset.//from w ww. j a va 2s .c o m * @param props the props * @return true if it exists */ protected boolean checkEngineCharSet(final Properties props) { final String databaseName = props.getProperty(DBNAME); DBMSUserMgr mgr = null; try { String itUsername = props.getProperty(DBUSERNAME); String itPassword = props.getProperty(DBPWD); String hostName = props.getProperty(HOSTNAME); if (!DBConnection.getInstance().isEmbedded()) { mgr = DBMSUserMgr.getInstance(); if (mgr.connectToDBMS(itUsername, itPassword, hostName)) { if (!mgr.verifyEngineAndCharSet(databaseName)) { String errMsg = mgr.getErrorMsg(); if (errMsg != null) { Object[] options = { getResourceString("CLOSE") }; JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), errMsg, getResourceString("DEL_CUR_DB_TITLE"), JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); } return false; } return true; } } else { return true; } } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifyDBSetupWizard.class, ex); } finally { if (mgr != null) { mgr.close(); } } return false; }
From source file:org.forester.archaeopteryx.TreePanel.java
final private void cutSubtree(final PhylogenyNode node) { if (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED) { errorMessageNoCutCopyPasteInUnrootedDisplay(); return;//from w w w. j a v a 2 s . c om } if (node.isRoot()) { JOptionPane.showMessageDialog(this, "Cannot cut entire tree as subtree", "Attempt to cut entire tree", JOptionPane.ERROR_MESSAGE); return; } final String label = getASimpleTextRepresentationOfANode(node); final int r = JOptionPane.showConfirmDialog(null, "Cut subtree" + label + "?", "Confirm Cutting of Subtree", JOptionPane.YES_NO_OPTION); if (r != JOptionPane.OK_OPTION) { return; } setCopiedAndPastedNodes(null); setCutOrCopiedTree(_phylogeny.subTree(node)); _phylogeny.deleteSubtree(node, true); _phylogeny.hashIDs(); _phylogeny.recalculateNumberOfExternalDescendants(true); resetNodeIdToDistToLeafMap(); setEdited(true); repaint(); }
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;// w w w .j av a 2s.c om } 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(); } }