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:net.chaosserver.timelord.swingui.AddTimeDialog.java
/** * @param evt the action event// www. j a v a 2s . c o m */ public void actionPerformed(ActionEvent evt) { if (ACTION_OK.equals(evt.getActionCommand())) { Object selectedItem = comboBox.getSelectedItem(); if (log.isDebugEnabled()) { log.debug("ComboBox selected item is [" + ((selectedItem == null) ? "null" : selectedItem.getClass().getName()) + "] with value [" + ((selectedItem == null) ? "null" : selectedItem) + "]"); } TimelordTask timelordTask = null; if (selectedItem instanceof TimelordTask) { timelordTask = (TimelordTask) selectedItem; } else if (selectedItem instanceof String) { String taskName = (String) selectedItem; int result = JOptionPane.showConfirmDialog(this, "Add new [" + taskName + "] Task?", "Add Task", JOptionPane.YES_NO_OPTION); if (result == 0) { timelordTask = timelordData.addTask(taskName); } } if (timelordTask != null) { TimelordTaskDay timelordTaskDay = timelordTask.getTaskDay(addDate, true); timelordTaskDay.addHours(DateUtil.getSmallestTimeIncremented()); if (timelordTask.isHidden()) { timelordTask.setHidden(true); } this.setVisible(false); } } }
From source file:com.tiempometa.muestradatos.JReadTags.java
private void deleteReadButtonActionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(this, "Se borrar el tag seleccionado.\nEsta operacin no se puede deshacer.\nContinuar?", "Borrar tags", JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.YES_OPTION) { try {// w ww . j a v a 2 s .com List<Rfid> rfids = tagTableModel.getData(); for (Rfid rfid : rfids) { rfidDao.delete(rfid); } tagTableModel.setData(new ArrayList<Rfid>()); tagTableModel.fireTableDataChanged(); } catch (SQLException e1) { JOptionPane.showMessageDialog(this, "No se pudieron borrar todos los tags. " + e1.getMessage(), "Error borrando tags", JOptionPane.ERROR_MESSAGE); } } }
From source file:csh.vctt.launcher.Launcher.java
/** * Prompt the user to select their character from a dialog. * @return Unique id number of the selected character. *///from w w w .j av a 2s . c o m private String getPlayerSelection() { String selectedId = "-1"; String outfitMembersJson = DataManager.execQuery(DataManager.M_OUTFITMEMBER_SELECT_QUERY); List<Player> outfitMembers = DataManager.getOutfitMembers(outfitMembersJson); Object[] outfitMembersArrObj = outfitMembers.toArray(); Player[] outfitMembersArr = new Player[outfitMembersArrObj.length]; for (int i = 0; i < outfitMembersArrObj.length; i++) { outfitMembersArr[i] = (Player) outfitMembersArrObj[i]; } JList<Player> memSelList = new JList<Player>(outfitMembersArr); memSelList.setVisibleRowCount(10); JScrollPane memScrollPane = new JScrollPane(memSelList); memScrollPane.setPreferredSize(new Dimension(200, 400)); int userAction = JOptionPane.showConfirmDialog(null, memScrollPane, "Select Character and Press Ok", JOptionPane.PLAIN_MESSAGE); Player selectedPlayer = null; if (userAction == JOptionPane.YES_OPTION) { selectedPlayer = memSelList.getSelectedValue(); } if (selectedPlayer != null) { selectedId = selectedPlayer.getId(); } return selectedId; }
From source file:com.mindcognition.mindraider.ui.swing.explorer.NotebooksTreeToolbar.java
public void actionPerformed(ActionEvent e) { // find notebook through node's user object URI, discard notebook (move it to the archive), // tags are preserved until notebook is erased DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) explorerJPanel.getNotebooksTree() .getLastSelectedPathComponent(); if (selectedNode.getDepth() == 0) { // it is leaf node - a notebook final String notebookUri = ((NotebookNodeUserObject) selectedNode.getUserObject()).getNotebookUri(); ResourceDescriptor resourceDescriptor = MindRaider.labelCustodian.getOutlineDescriptor(notebookUri); if (JOptionPane.showConfirmDialog(MindRaider.mainJFrame, "Do you really want to discard Outline '" + (resourceDescriptor != null ? resourceDescriptor.getLabel() : notebookUri) + "'?", "Archive Outline", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { // discard the notebook from ALL folders where it presents MindRaider.labelCustodian.discardOutline(notebookUri); explorerJPanel.refresh();//from w ww . ja v a2 s . c o m OutlineJPanel.getInstance().clear(); MindRaider.spidersGraph.clear(); MindRaider.profile.setActiveOutlineUri(null); return; } } else { JOptionPane.showMessageDialog(MindRaider.mainJFrame, "Please select Outline to be discarded!"); } }
From source file:fi.elfcloud.client.tree.ClusterHierarchyModel.java
public void removeSelected(TreePath[] paths) { if (paths.length == 1) { ClusterTreeNode node = (ClusterTreeNode) paths[0].getLastPathComponent(); String dialogTitle = Messages.getString("ClusterHierarchyModel.title_vault_remove_dialog"); //$NON-NLS-1$ if (node instanceof DataItemNode) { dialogTitle = Messages.getString("ClusterHierarchyModel.title_dataitem_remove_dialog"); //$NON-NLS-1$ } else if (node.getParentId() > 0) { dialogTitle = Messages.getString("ClusterHierarchyModel.title_cluster_remove_dialog"); //$NON-NLS-1$ }//from w w w. java2s . c o m int n = JOptionPane.showConfirmDialog(null, Messages.getString("ClusterHierarchyModel.dialog_remove_question") + node.getName() + "?", //$NON-NLS-1$ //$NON-NLS-2$ dialogTitle, JOptionPane.YES_NO_OPTION); switch (n) { case JOptionPane.YES_OPTION: removePaths(paths); break; default: break; } } else if (paths.length > 1) { int n = JOptionPane.showConfirmDialog(null, Messages.getString("ClusterHierarchyModel.dialog_remove_multiple_items_question"), //$NON-NLS-1$ Messages.getString("ClusterHierarchyModel.dialog_remove_multiple_items_title_1") //$NON-NLS-1$ + Integer.toString(paths.length) + Messages.getString("ClusterHierarchyModel.dialog_remove_multiple_items_title_2"), //$NON-NLS-1$ JOptionPane.YES_NO_OPTION); switch (n) { case JOptionPane.YES_OPTION: removePaths(paths); break; default: break; } } }
From source file:nosqltools.MainForm.java
/** * Creates new form MainForm and sets the necessary properties for the main * form/* ww w . j a v a 2s . c o m*/ */ public MainForm() { Image img = null; try { img = ImageIO.read(new File("resources/mongoicon.png")); } catch (IOException e) { } this.setIconImage(img); initComponents(); setExtendedState(JFrame.MAXIMIZED_BOTH); fc.setFileFilter(filter); textArea = new RSyntaxTextArea(20, 60); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JSON); textArea.setCodeFoldingEnabled(true); textArea.setAntiAliasingEnabled(true); Table_JSON.addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(java.awt.event.MouseEvent evt) { int row = Table_JSON.rowAtPoint(evt.getPoint()); int col = Table_JSON.columnAtPoint(evt.getPoint()); JOptionPane.showMessageDialog(null, "Value in the cell clicked :" + " " + Table_JSON.getValueAt(row, col).toString()); if (json_util.isArray(Table_JSON.getValueAt(row, col).toString())) { if (JOptionPane.showConfirmDialog(null, "View the array as a table:", "VIEW", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.YES_OPTION) { Panel_Views.setEnabled(false); Panel_Connections.setEnabled(false); jMenuBar1.setEnabled(false); if (row >= 0 && col >= 0) { TableForm tableForm = new TableForm(Table_JSON.getValueAt(row, col).toString()); } } } } }); RTextScrollPane sp = new RTextScrollPane(textArea); sp.setFoldIndicatorEnabled(true); Panel_Text.add(sp); Save_File.setEnabled(false); Panel_Text.setVisible(false); Panel_Table.setVisible(false); Panel_Hierarchical.setVisible(false); Panel_Compare.setVisible(false); Panel_Compare_Upper.setVisible(false); Panel_Connect.setVisible(false); util.changeTextAreaTheme(textArea); }
From source file:edu.ku.brc.af.ui.PopupDlg.java
/** * Brings up a JOptionPane where the number of choices is determined by the optionType parameter. Includes a checkbox that allows the user * to request that this popup dialog is not shown again, the message that indicates this is provided as a parameter * /*ww w . ja v a 2 s . c om*/ * @param parent - determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used * @param message - the String message to display * @param title - the title string for the dialog * @param doNotAgainMessage - the message to be displayed that tells the user "do not ask again" * @param optionType - an integer designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION * @param callingClassname - the name of the class that called this method * @param dialogNumber - uniquely identifying id for this dialog * @return * int - an integer indicating the option selected by the user */ public static int showConfirmDialog(Component parent, String message, String title, String doNotAgainMessage, int optionType, String callingClassname, int dialogNumber) { PopupDlgPrefsMgr popupMgr = new PopupDlgPrefsMgr(); int dialogId = popupMgr.generatePopupDialogId(title, message, callingClassname + dialogNumber); boolean dontShow = popupMgr.isDialogDisabled(dialogId); if (!dontShow) { PopupDlgContent components = null; if (StringUtils.isBlank(doNotAgainMessage)) components = new PopupDlgContent(message); else components = new PopupDlgContent(message, doNotAgainMessage); int response = JOptionPane.showConfirmDialog(parent, components.getComponents(), title, optionType); boolean disableMe = components.isCheckboxSelected(); if (disableMe) { log.debug("User has selected to disable the popup"); popupMgr.disableDialog(dialogId, response); } else { log.debug("User has selected not to disable the popup"); } return response; } return popupMgr.getDisabledDialogOptionSelection(dialogId); }
From source file:org.cds06.speleograph.graph.SeriesMenu.java
private JPopupMenu createPopupMenuForSeries(final Series series) { if (series == null) return new JPopupMenu(); final JPopupMenu menu = new JPopupMenu(series.getName()); menu.removeAll();/*www .j a v a2 s . c o m*/ menu.add(new AbstractAction() { { putValue(NAME, "Renommer la srie"); } @Override public void actionPerformed(ActionEvent e) { menu.setVisible(false); String newName = ""; while (newName == null || newName.equals("")) { newName = (String) JOptionPane.showInputDialog(application, "Entrez un nouveau nom pour la srie", null, JOptionPane.QUESTION_MESSAGE, null, null, series.getName()); } series.setName(newName); } }); if (series.hasOwnAxis()) { menu.add(new AbstractAction() { { putValue(NAME, "Supprimer l'axe spcifique"); } @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes vous sr de vouloir supprimer cet axe ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { series.setAxis(null); } } }); } else { menu.add(new JMenuItem(new AbstractAction() { { putValue(NAME, "Crer un axe spcifique pour la srie"); } @Override public void actionPerformed(ActionEvent e) { String name = JOptionPane.showInputDialog(application, "Quel titre pour cet axe ?", series.getAxis().getLabel()); if (name == null || "".equals(name)) return; // User has canceled series.setAxis(new NumberAxis(name)); } })); } menu.add(new SetTypeMenu(series)); if (series.isWater()) { menu.addSeparator(); menu.add(new SumOnPeriodAction(series)); menu.add(new CreateCumulAction(series)); } if (series.isWaterCumul()) { menu.addSeparator(); menu.add(new SamplingAction(series)); } if (series.isPressure()) { menu.addSeparator(); menu.add(new CorrelateAction(series)); menu.add(new WaterHeightAction(series)); } menu.addSeparator(); menu.add(new AbstractAction() { { String name; if (series.canUndo()) name = "Annuler " + series.getItemsName(); else name = series.getLastUndoName(); putValue(NAME, name); if (series.canUndo()) setEnabled(true); else { setEnabled(false); } } @Override public void actionPerformed(ActionEvent e) { series.undo(); } }); menu.add(new AbstractAction() { { String name; if (series.canRedo()) { name = "Refaire " + series.getNextRedoName(); setEnabled(true); } else { name = series.getNextRedoName(); setEnabled(false); } putValue(NAME, name); } @Override public void actionPerformed(ActionEvent e) { series.redo(); } }); menu.add(new AbstractAction() { { putValue(NAME, I18nSupport.translate("menus.serie.resetSerie")); if (series.canUndo()) setEnabled(true); else setEnabled(false); } @Override public void actionPerformed(ActionEvent e) { series.reset(); } }); menu.add(new LimitDateRangeAction(series)); menu.add(new HourSettingAction(series)); menu.addSeparator(); { JMenuItem deleteItem = new JMenuItem("Supprimer la srie"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes-vous sur de vouloir supprimer cette srie ?\n" + "Cette action est dfinitive.", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { series.delete(); } } }); menu.add(deleteItem); } menu.addSeparator(); { final JMenuItem up = new JMenuItem("Remonter dans la liste"), down = new JMenuItem("Descendre dans la liste"); ActionListener listener = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (e.getSource().equals(up)) { series.upSeriesInList(); } else { series.downSeriesInList(); } } }; up.addActionListener(listener); down.addActionListener(listener); if (series.isFirst()) { menu.add(down); } else if (series.isLast()) { menu.add(up); } else { menu.add(up); menu.add(down); } } menu.addSeparator(); { menu.add(new SeriesInfoAction(series)); } { JMenuItem colorItem = new JMenuItem("Couleur de la srie"); colorItem.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { series.setColor(JColorChooser.showDialog(application, I18nSupport.translate("actions.selectColorForSeries"), series.getColor())); } }); menu.add(colorItem); } { JMenu plotRenderer = new JMenu("Affichage de la srie"); final ButtonGroup modes = new ButtonGroup(); java.util.List<DrawStyle> availableStyles; if (series.isMinMax()) { availableStyles = DrawStyles.getDrawableStylesForHighLow(); } else { availableStyles = DrawStyles.getDrawableStyles(); } for (final DrawStyle s : availableStyles) { final JRadioButtonMenuItem item = new JRadioButtonMenuItem(DrawStyles.getHumanCheckboxText(s)); item.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (item.isSelected()) series.setStyle(s); } }); modes.add(item); if (s.equals(series.getStyle())) { modes.setSelected(item.getModel(), true); } plotRenderer.add(item); } menu.add(plotRenderer); } menu.addSeparator(); menu.add(new AbstractAction() { { putValue(Action.NAME, "Fermer le fichier"); } @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes-vous sur de vouloir fermer toutes les sries du fichier ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { final File f = series.getOrigin(); for (final Series s : Series.getInstances().toArray(new Series[Series.getInstances().size()])) { if (s.getOrigin().equals(f)) s.delete(); } } } }); return menu; }
From source file:grafix.principal.Comandos.java
static public void cmdAplicarDefault() { ControleRegistro.alertaRegistro();/*from w w w . j a va 2 s .com*/ try { if (JOptionPane.showConfirmDialog(Controle.getTela(), "Deseja desfazer todas as configuraes da janela?", "Confirmar ao", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { Controle.getJanelaAtiva().setConfiguracoesJanela(new ConfiguracoesJanela()); Controle.getTela().atualizarJanelasGraficos(); } } catch (Exception ex) { semJanelaAtiva(); } }
From source file:com.tiempometa.muestradatos.JMuestraDatos.java
public JMuestraDatos() { initComponents();/*from w w w .j av a 2 s .c o m*/ this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { int response = JOptionPane.showConfirmDialog(null, "Seguro que deseas cerrar la aplicacin?", "Cerrar Programa", JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.YES_OPTION) { ReaderContext.stopReading(); try { Thread.sleep(2000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { ReaderContext.disconnectUsbReader(); } catch (ReaderException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.exit(0); } } }); loadSettings(); if (ReaderContext.getSettings().getDatabaseName() == null) { JOptionPane.showMessageDialog(this, "No se ha configurado la aplicacin.\nFavor de configurar antes de continuar", "Sin configuracin", JOptionPane.WARNING_MESSAGE); } else { setDatabase(new File(ReaderContext.getSettings().getDatabaseName())); } ReaderContext.addReadingListener(this); ReaderContext.addReaderStatusListener(this); Thread thread = new Thread(systemTime); thread.start(); }