List of usage examples for javax.swing JOptionPane showConfirmDialog
public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon) throws HeadlessException
optionType
parameter. From source file:Main.java
public static void main(String[] args) { Image image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); JPanel gui = new JPanel(new BorderLayout()); JLabel clouds = new JLabel(new ImageIcon(new BufferedImage(250, 100, BufferedImage.TYPE_INT_RGB))); gui.add(clouds);/*from w w w . j a v a 2s . com*/ JOptionPane.showConfirmDialog(null, gui, "Title", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, new ImageIcon(image)); }
From source file:com.igormaznitsa.sciareto.ui.UiUtils.java
public static boolean msgOkCancel(@Nonnull final String title, @Nonnull final Object component) { return JOptionPane.showConfirmDialog(Main.getApplicationFrame(), component, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null) == JOptionPane.OK_OPTION; }
From source file:com.pingtel.sipviewer.SIPViewerFrame.java
public void applyAliasesFile(String strAliasesFile) { try {//from ww w . jav a 2 s.c o m FileReader fr = new FileReader(strAliasesFile); BufferedReader reader = new BufferedReader(fr); String strLine = reader.readLine(); while (strLine != null) { int pos = strLine.indexOf("="); if (pos > 0) { String strValue = strLine.substring(0, pos); String strKey = strLine.substring(pos + 1); strKey = strKey.trim(); strValue = strValue.trim(); // System.out.println("AddAlias: " + strValue + " -> " + // strKey) ; m_model.removeKey(strValue); m_model.addKeyAlias(strKey, strValue); m_model.reindexData(); } strLine = reader.readLine(); } reader.close(); fr.close(); } catch (Exception e) { System.out.println("Unable to apply aliases file: " + strAliasesFile); JOptionPane.showConfirmDialog(null, "Unable to apply aliases file: " + strAliasesFile, "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null); e.printStackTrace(); this.dispose(); } }
From source file:coolmap.canvas.datarenderer.renderer.impl.NumberComposite.java
public NumberComposite() { setName("Number to Composite"); // System.out.println("Created a new NumberComposite"); setDescription("A renderer that can be used to assign renderers to different aggregations"); configUI.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0;/*from ww w. j av a2s. com*/ c.gridy = 0; c.ipadx = 5; c.ipady = 5; c.insets = new Insets(2, 2, 2, 2); c.gridwidth = 1; //This combo box will need to be able to add registered singleComboBox = new JComboBox(); rowComboBox = new JComboBox(); columnComboBox = new JComboBox(); rowColumnComboBox = new JComboBox(); singleLegend = new JLabel(); rowLegend = new JLabel(); columnLegend = new JLabel(); rowColumnLegend = new JLabel(); singleLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); rowLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); columnLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); rowColumnLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); //Add them JLabel label = new JLabel("Default:"); label.setToolTipText("Default renderer"); c.gridx = 0; c.gridy++; configUI.add(label, c); c.gridx = 1; configUI.add(singleComboBox, c); singleComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateRenderer(); } } }); c.gridx = 2; JButton config = new JButton(UI.getImageIcon("gear")); configUI.add(config, c); config.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (singleRenderer == null) { return; } // JOptionPane.showmess int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), singleRenderer.getConfigUI(), "Default Renderer Config", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null); if (returnVal == JOptionPane.OK_OPTION) { updateRenderer(); } } }); c.gridx = 1; c.gridy++; c.gridwidth = 1; configUI.add(singleLegend, c); ////////////////////////////////////////////////////////////// c.gridx = 0; c.gridy++; c.gridwidth = 1; label = new JLabel("Row Group:"); label.setToolTipText("Renderer for row ontology nodes"); configUI.add(label, c); c.gridx = 1; configUI.add(rowComboBox, c); c.gridx++; config = new JButton(UI.getImageIcon("gear")); configUI.add(config, c); config.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (rowGroupRenderer == null) { return; } // JOptionPane.showmess int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), rowGroupRenderer.getConfigUI(), "Row Group Renderer Config", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null); if (returnVal == JOptionPane.OK_OPTION) { updateRenderer(); } } }); rowComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateRenderer(); } } }); c.gridx = 1; c.gridy++; c.gridwidth = 1; configUI.add(rowLegend, c); c.gridx = 0; c.gridy++; c.gridwidth = 1; label = new JLabel("Column Group:"); label.setToolTipText("Renderer for column ontology nodes"); configUI.add(label, c); c.gridx = 1; configUI.add(columnComboBox, c); c.gridx++; config = new JButton(UI.getImageIcon("gear")); configUI.add(config, c); config.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (columnGroupRenderer == null) { return; } // JOptionPane.showmess int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), columnGroupRenderer.getConfigUI(), "Column Group Renderer Config", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null); if (returnVal == JOptionPane.OK_OPTION) { updateRenderer(); } } }); c.gridx = 1; c.gridy++; c.gridwidth = 1; configUI.add(columnLegend, c); columnComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateRenderer(); } } }); c.gridx = 0; c.gridy++; c.gridwidth = 1; label = new JLabel("Row & Column Group:"); label.setToolTipText("Renderer for row and column ontology nodes"); configUI.add(label, c); c.gridx = 1; configUI.add(rowColumnComboBox, c); c.gridx++; config = new JButton(UI.getImageIcon("gear")); configUI.add(config, c); config.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (rowColumnGroupRenderer == null) { return; } // JOptionPane.showmess int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), rowColumnGroupRenderer.getConfigUI(), "Row + Column Group Renderer Config", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null); if (returnVal == JOptionPane.OK_OPTION) { updateRenderer(); } } }); rowColumnComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateRenderer(); } } }); c.gridx = 1; c.gridy++; c.gridwidth = 1; configUI.add(rowColumnLegend, c); JButton button = new JButton("Apply Changes", UI.getImageIcon("refresh")); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateRenderer(); } }); c.gridx = 0; c.gridy++; c.gridwidth = 2; configUI.add(button, c); singleComboBox.setRenderer(new ComboRenderer()); rowComboBox.setRenderer(new ComboRenderer()); columnComboBox.setRenderer(new ComboRenderer()); rowColumnComboBox.setRenderer(new ComboRenderer()); _updateLists(); }
From source file:edu.ku.brc.af.ui.PopupDlg.java
/** * Brings up a JOptionPane with a specified icon, 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. * /*from w w w. j av a2 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 messageType - an integer designating the kind of message this is; primarily used to determine the icon from the pluggable Look and Feel: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE * @param icon - icon - the icon to display in the dialog * @param callingClassname - the name of the class that called this method * @param dialogNumber - uniquely identifying id for this dialog * @return * int - an int indicating the option selected by the user */ public static int showConfimDialog(Component parent, String message, String title, String doNotAgainMessage, int optionType, int messageType, Icon icon, 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 = new PopupDlgContent(message, doNotAgainMessage); int response = JOptionPane.showConfirmDialog(parent, components.getComponents(), title, optionType, messageType, icon); 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:fi.smaa.jsmaa.gui.JSMAAMainFrame.java
private boolean checkSaveCurrentModel() { if (!modelManager.getSaved()) { int conf = JOptionPane.showConfirmDialog(this, "Current model not saved. Do you want do save changes?", "Save changed", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_STOP)); if (conf == JOptionPane.CANCEL_OPTION) { return false; } else if (conf == JOptionPane.YES_OPTION) { if (!save()) { return false; }/*from www .j a va 2 s . c o m*/ } } return true; }
From source file:fi.smaa.jsmaa.gui.SMAATRIGUIFactory.java
@Override protected void confirmDeleteAlternative(Alternative alternative) { if (!smaaModel.getCategories().contains(alternative)) { super.confirmDeleteAlternative(alternative); } else {// w w w.j a v a 2s .c o m String typeName = "category"; int conf = JOptionPane.showConfirmDialog(parent, "Do you really want to delete " + typeName + " " + alternative + "?", "Confirm deletion", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_DELETE)); if (conf == JOptionPane.YES_OPTION) { smaaModel.deleteCategory(alternative); } } }
From source file:com.konifar.material_icon_generator.MaterialDesignIconGenerateDialog.java
@Override protected void doOKAction() { if (model == null) return;/*from www . jav a 2 s. co m*/ if (!isConfirmed()) return; if (alreadyFileExists()) { final int option = JOptionPane.showConfirmDialog(panelMain, "File already exists, overwrite this ?", "File exists", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, new ImageIcon(getClass().getResource(ICON_WARNING))); if (option == JOptionPane.YES_OPTION) { create(); } } else { create(); } }
From source file:com.sshtools.common.vomanagementtool.common.VOHelper.java
public static boolean checkFavouritesChanges() { boolean isChanged = false; Map favourites = (TreeMap) VOHelper.getVOGroup(FAVOURITES); Map egis = (TreeMap) VOHelper.getVOGroup(EGI); Map others = (TreeMap) VOHelper.getVOGroup(OTHERS); Iterator<Map.Entry<String, List>> entries = favourites.entrySet().iterator(); while (entries.hasNext()) { Entry<String, List> favourite = entries.next(); String favVOName = favourite.getKey(); List voDetails = favourite.getValue(); for (int i = 0; i < voDetails.size(); i++) { TreeMap favInfo = (TreeMap) voDetails.get(i); boolean isSame = false; String group = ""; if (egis.containsKey(favVOName)) { List egiVODetails = (List) egis.get(favVOName); isSame = compareTreeMapInList(favVOName, favInfo, egiVODetails); group = EGI;//from www.j av a 2s . c om } else if (others.containsKey(favVOName)) { List othersVODetails = (List) others.get(favVOName); isSame = compareTreeMapInList(favVOName, favInfo, othersVODetails); group = OTHERS; } if (!isSame && !group.equals("")) { int reply = JOptionPane.showConfirmDialog(null, "VO '" + favVOName + "' setup has been modified in " + group + " setup. Your " + FAVOURITES + " configuration might not work.\n Do you want to update Favourites with the updated configurations?", "Update " + FAVOURITES + " configuration", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, new ResourceIcon(VOHelper.class, ConfigHelper.ICON)); if (reply == JOptionPane.OK_OPTION) { if (group.equals(EGI)) { favourites.put(favVOName, egis.get(favVOName)); isChanged = true; } else if (group.equals(OTHERS)) { favourites.put(favVOName, others.get(favVOName)); isChanged = true; } break; } } } } if (isChanged) { String newContent = createStringFromTreeMap((TreeMap) favourites); try { writeToFile(favouritesFile, newContent); } catch (IOException e) { isChanged = false; JOptionPane.showMessageDialog(null, "Failed to remove VO from Favourites. Cannot write to file '" + favouritesFile + "'", "Error: Remove VO", JOptionPane.ERROR_MESSAGE); } } return isChanged; }
From source file:com.konifar.material_icon_generator.MaterialDesignIconGenerateDialog.java
private void create() { if (model.isMdpi()) createIcon(checkBoxMdpi.getText()); if (model.isHdpi()) createIcon(checkBoxHdpi.getText()); if (model.isXhdpi()) createIcon(checkBoxXhdpi.getText()); if (model.isXxhdpi()) createIcon(checkBoxXxhdpi.getText()); if (model.isXxxhdpi()) createIcon(checkBoxXxxhdpi.getText()); JOptionPane.showConfirmDialog(panelMain, "Icon created successfully.", "Material design icon created", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, new ImageIcon(getClass().getResource(ICON_DONE))); }