List of usage examples for javax.swing JOptionPane QUESTION_MESSAGE
int QUESTION_MESSAGE
To view the source code for javax.swing JOptionPane QUESTION_MESSAGE.
Click Source Link
From source file:net.sf.jabref.exporter.SaveDatabaseAction.java
private boolean saveDatabase(File file, boolean selectedOnly, Charset encoding) throws SaveException { SaveSession session;// w w w . j a v a 2 s .c o m frame.block(); try { SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs) .withEncoding(encoding); BibDatabaseWriter databaseWriter = new BibDatabaseWriter(); if (selectedOnly) { session = databaseWriter.savePartOfDatabase(panel.getBibDatabaseContext(), prefs, panel.getSelectedEntries()); } else { session = databaseWriter.saveDatabase(panel.getBibDatabaseContext(), prefs); } panel.registerUndoableChanges(session); } catch (UnsupportedCharsetException ex2) { JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + Localization .lang("Character encoding '%0' is not supported.", encoding.displayName()), Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE); throw new SaveException("rt"); } catch (SaveException ex) { if (ex == SaveException.FILE_LOCKED) { throw ex; } if (ex.specificEntry()) { // Error occured during processing of // be. Highlight it: int row = panel.mainTable.findEntry(ex.getEntry()); int topShow = Math.max(0, row - 3); panel.mainTable.setRowSelectionInterval(row, row); panel.mainTable.scrollTo(topShow); panel.showEntry(ex.getEntry()); } else { LOGGER.error("Problem saving file", ex); } JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + ".\n" + ex.getMessage(), Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE); throw new SaveException("rt"); } finally { frame.unblock(); } boolean commit = true; if (!session.getWriter().couldEncodeAll()) { FormBuilder builder = FormBuilder.create() .layout(new FormLayout("left:pref, 4dlu, fill:pref", "pref, 4dlu, pref")); JTextArea ta = new JTextArea(session.getWriter().getProblemCharacters()); ta.setEditable(false); builder.add(Localization.lang("The chosen encoding '%0' could not encode the following characters:", session.getEncoding().displayName())).xy(1, 1); builder.add(ta).xy(3, 1); builder.add(Localization.lang("What do you want to do?")).xy(1, 3); String tryDiff = Localization.lang("Try different encoding"); int answer = JOptionPane.showOptionDialog(frame, builder.getPanel(), Localization.lang("Save database"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[] { Localization.lang("Save"), tryDiff, Localization.lang("Cancel") }, tryDiff); if (answer == JOptionPane.NO_OPTION) { // The user wants to use another encoding. Object choice = JOptionPane.showInputDialog(frame, Localization.lang("Select encoding"), Localization.lang("Save database"), JOptionPane.QUESTION_MESSAGE, null, Encodings.ENCODINGS_DISPLAYNAMES, encoding); if (choice == null) { commit = false; } else { Charset newEncoding = Charset.forName((String) choice); return saveDatabase(file, selectedOnly, newEncoding); } } else if (answer == JOptionPane.CANCEL_OPTION) { commit = false; } } try { if (commit) { session.commit(file); panel.setEncoding(encoding); // Make sure to remember which encoding we used. } else { session.cancel(); } } catch (SaveException e) { int ans = JOptionPane.showConfirmDialog(null, Localization.lang("Save failed during backup creation") + ". " + Localization.lang("Save without backup?"), Localization.lang("Unable to create backup"), JOptionPane.YES_NO_OPTION); if (ans == JOptionPane.YES_OPTION) { session.setUseBackup(false); session.commit(file); panel.setEncoding(encoding); } else { commit = false; } } return commit; }
From source file:gdt.jgui.entity.JEntitiesPanel.java
/** * Get context menu./*from w w w. j a v a 2 s . co m*/ * @return the context menu. * */ @Override public JMenu getContextMenu() { menu = super.getContextMenu(); mia = null; int cnt = menu.getItemCount(); if (cnt > 0) { 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) { menu.removeAll(); if (mia != null) for (JMenuItem mi : mia) try { if (mi != null) menu.add(mi); } catch (Exception ee) { System.out.println("JEntitiesPanel:getConextMenu:" + ee.toString()); } Properties locator = Locator.toProperties(locator$); if (locator.getProperty(EntityHandler.ENTITY_CONTAINER) != null) { if (JEntityPrimaryMenu.hasToPaste(console, locator$)) { pasteItem = new JMenuItem("Paste components"); pasteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { pasteComponents(); } }); menu.add(pasteItem); } if (hasSelectedItems()) { if (containerKey$ != null) { removeComponentsItem = new JMenuItem("Remove components"); removeComponentsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeComponents(); } }); menu.add(removeComponentsItem); } } } if (locator.getProperty(EntityHandler.ENTITY_COMPONENT) != null) { if (componentKey$ != null) { removeContainersItem = new JMenuItem("Remove containers"); removeContainersItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeContainers(); } }); menu.add(removeContainersItem); } } if (hasSelectedItems()) { menu.addSeparator(); copyItem = new JMenuItem("Copy"); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JItemPanel[] ipa = JEntitiesPanel.this.getItems(); ArrayList<String> sl = new ArrayList<String>(); for (JItemPanel ip : ipa) if (ip.isChecked()) sl.add(ip.getLocator()); String[] sa = sl.toArray(new String[0]); console.clipboard.clear(); for (String aSa : sa) console.clipboard.putString(aSa); } }); menu.add(copyItem); reindexItem = new JMenuItem("Reindex"); reindexItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JItemPanel[] ipa = JEntitiesPanel.this.getItems(); for (JItemPanel ip : ipa) if (ip.isChecked()) { JEntityPrimaryMenu.reindexEntity(console, ip.getLocator()); } } }); menu.add(reindexItem); archiveItem = new JMenuItem("Archive"); archiveItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JItemPanel[] ipa = JEntitiesPanel.this.getItems(); Entigrator entigrator = console.getEntigrator(entihome$); Properties locator; ArrayList<String> sl = new ArrayList<String>(); String entityKey$; for (JItemPanel ip : ipa) { if (ip.isChecked()) { locator = Locator.toProperties(ip.getLocator()); entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); sl.add(entityKey$); } } String[] sa = sl.toArray(new String[0]); System.out.println("JEntitiesPanel:archive:1"); String[] ea = JReferenceEntry.getCoalition(console, entigrator, sa); if (ea == null) System.out.println("JEntitiesPanel:archive:ea null"); else System.out.println("JEntitiesPanel:archive:ea=" + ea.length); JArchivePanel archivePanel = new JArchivePanel(); String apLocator$ = archivePanel.getLocator(); //locator$=getLocator(); apLocator$ = Locator.append(apLocator$, Entigrator.ENTIHOME, entihome$); apLocator$ = Locator.append(apLocator$, EntityHandler.ENTITY_LIST, Locator.toString(ea)); String icon$ = Support.readHandlerIcon(null, JEntityPrimaryMenu.class, "archive.png"); apLocator$ = Locator.append(apLocator$, Locator.LOCATOR_ICON, icon$); JConsoleHandler.execute(console, apLocator$); } }); menu.add(archiveItem); menu.addSeparator(); 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) { JItemPanel[] ipa = JEntitiesPanel.this.getItems(); Entigrator entigrator = console.getEntigrator(entihome$); String iLocator$; Properties iLocator; String iEntityKey$; String iEntityLabel$; Sack iEntity; ArrayList<String> sl = new ArrayList<String>(); for (JItemPanel ip : ipa) { iLocator$ = ip.getLocator(); iLocator = Locator.toProperties(iLocator$); iEntityLabel$ = iLocator.getProperty(EntityHandler.ENTITY_LABEL); if (ip.isChecked()) { iEntityKey$ = iLocator.getProperty(EntityHandler.ENTITY_KEY); iEntity = entigrator.getEntityAtKey(iEntityKey$); if (iEntity != null) entigrator.deleteEntity(iEntity); } else { sl.add(iEntityLabel$); } } String[] sa = sl.toArray(new String[0]); if (sa != null && sa.length > 0) { String sa$ = Locator.toString(sa); locator$ = Locator.append(locator$, EntityHandler.ENTITY_LIST, sa$); } JConsoleHandler.execute(console, locator$); } } }); menu.add(deleteItem); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); menu.addSeparator(); 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.severe(ee.toString()); } } else console.back(); } }); menu.add(doneItem); return menu; }
From source file:me.childintime.childintime.InitialSetup.java
/** * Show the confirmation dialog.//from ww w . j a va 2s.c o m * * @return True if the user agree'd, false if not. */ private boolean showConfirmationDialog() { // Create a list with the buttons to show in the option dialog List<String> buttons = new ArrayList<>(); buttons.add("Continue"); buttons.add("Quit"); // Reverse the button list if we're on a Mac OS X system if (Platform.isMacOsX()) Collections.reverse(buttons); // Show the option dialog final int option = JOptionPane.showOptionDialog(this.progressDialog, "This is the first time you're using " + App.APP_NAME + " on this system.\n" + "Some application files are required to be installed.\n" + "Please Continue and allow us to set things up for you.", App.APP_NAME + " - Initial setup", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, buttons.toArray(), buttons.get(!Platform.isMacOsX() ? 0 : 1)); // Determine, set and return the result this.confirmDialogAgree = (option == (!Platform.isMacOsX() ? 0 : 1)); return this.confirmDialogAgree; }
From source file:at.becast.youploader.gui.FrmMain.java
/** * Creates new form frmMain/*from w w w . j a v a 2 s .c o m*/ */ public FrmMain() { self = this; this.tos = false; this.setMinimumSize(new Dimension(900, 580)); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { LOG.info(Main.APP_NAME + " " + Main.VERSION + " closing.", FrmMain.class); Main.s.put("left", String.valueOf(getX())); Main.s.put("top", String.valueOf(getY())); Main.s.put("width", String.valueOf(getWidth())); Main.s.put("height", String.valueOf(getHeight())); LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); loggerContext.stop(); e.getWindow().dispose(); } }); UploadMgr = UploadManager.getInstance(); TemplateMgr = TemplateManager.getInstance(); UploadMgr.setParent(this); String sspeed = Main.s.setting.get("speed"); if (sspeed != null) { speed = Integer.parseInt(sspeed); } else { speed = 0; } initComponents(); initMenuBar(); loadAccounts(); this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/yp.png"))); try { loadQueue(); } catch (SQLException | IOException e) { LOG.error("Error: ", e); } this.setVisible(true); if (Main.firstlaunch) { int n = JOptionPane.showConfirmDialog(null, LANG.getString("frmMain.initialAccount.Message"), LANG.getString("frmMain.initialAccount.title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (n == JOptionPane.YES_OPTION) { mntmAddAccountActionPerformed(); } } else { PlaylistUpdater pu = new PlaylistUpdater(this); Thread updater = new Thread(pu); updater.start(); AccountUpdater au = new AccountUpdater(this); Thread aupdater = new Thread(au); aupdater.start(); } EditPanel edit = (EditPanel) ss1.contentPane; if (edit.getCmbTemplate().getModel().getSize() > 0) { edit.getCmbTemplate().setSelectedIndex(0); } tray = new TrayManager(this); addWindowStateListener(new WindowStateListener() { public void windowStateChanged(WindowEvent e) { if (e.getNewState() == ICONIFIED) { tray.add(); setVisible(false); } if (e.getNewState() == 7) { tray.add(); setVisible(false); } if (e.getNewState() == MAXIMIZED_BOTH) { tray.remove(); setVisible(true); } if (e.getNewState() == NORMAL) { tray.remove(); setVisible(true); } } }); }
From source file:com.jvms.i18neditor.Editor.java
public void showAddLocaleDialog(ResourceType type) { String locale = ""; while (locale != null && locale.isEmpty()) { locale = (String) JOptionPane.showInputDialog(this, MessageBundle.get("dialogs.locale.add.text"), MessageBundle.get("dialogs.locale.add.title", type.toString()), JOptionPane.QUESTION_MESSAGE); if (locale != null) { locale = locale.trim();/*from www. java2s .c om*/ Path path = Paths.get(resourcesDir.toString(), locale); if (locale.isEmpty() || Files.isDirectory(path)) { showError(MessageBundle.get("dialogs.locale.add.error.invalid")); } else { try { Resource resource = Resources.create(type, path); setupResource(resource); updateUI(); } catch (IOException e) { e.printStackTrace(); showError(MessageBundle.get("dialogs.locale.add.error.create")); } } } } }
From source file:com.a544jh.kanamemory.ui.ProfileChooserPanel.java
private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed if (JOptionPane.showConfirmDialog(this, "Are you sure?", "Delete Profile", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { JsonFileWriter.deleteProfile((String) profilesList.getSelectedValue(), "profiles"); populateList();/*from w ww . ja va 2s . c o m*/ } }
From source file:edu.ku.brc.af.auth.UserAndMasterPasswordMgr.java
/** * @return// w ww .j a va 2s.c o m */ protected int askToContForCredentials() { int userChoice = JOptionPane.NO_OPTION; Object[] options = { getResourceString("Continue"), //$NON-NLS-1$ getResourceString("CANCEL") //$NON-NLS-1$ }; loadAndPushResourceBundle("masterusrpwd"); userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), getLocalizedMessage("MISSING_CREDS", usersUserName), //$NON-NLS-1$ getResourceString("MISSING_CREDS_TITLE"), //$NON-NLS-1$ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); popResourceBundle(); return userChoice; }
From source file:org.jfree.chart.demo.JFreeChartDemo.java
/** * Exits the application, but only if the user agrees. */// w ww . j a v a2 s . co m private void attemptExit() { final String title = this.resources.getString("dialog.exit.title"); final String message = this.resources.getString("dialog.exit.message"); final int result = JOptionPane.showConfirmDialog(this, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.YES_OPTION) { dispose(); System.exit(0); } }
From source file:net.sf.jabref.gui.exporter.SaveDatabaseAction.java
private boolean saveDatabase(File file, boolean selectedOnly, Charset encoding) throws SaveException { SaveSession session;//from w w w.j ava 2 s. co m frame.block(); try { SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs) .withEncoding(encoding); BibtexDatabaseWriter databaseWriter = new BibtexDatabaseWriter(FileSaveSession::new); if (selectedOnly) { session = databaseWriter.savePartOfDatabase(panel.getBibDatabaseContext(), panel.getSelectedEntries(), prefs); } else { session = databaseWriter.saveDatabase(panel.getBibDatabaseContext(), prefs); } panel.registerUndoableChanges(session); } catch (UnsupportedCharsetException ex2) { JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + Localization .lang("Character encoding '%0' is not supported.", encoding.displayName()), Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE); throw new SaveException("rt"); } catch (SaveException ex) { if (ex == SaveException.FILE_LOCKED) { throw ex; } if (ex.specificEntry()) { // Error occured during processing of // be. Highlight it: int row = panel.getMainTable().findEntry(ex.getEntry()); int topShow = Math.max(0, row - 3); panel.getMainTable().setRowSelectionInterval(row, row); panel.getMainTable().scrollTo(topShow); panel.showEntry(ex.getEntry()); } else { LOGGER.error("Problem saving file", ex); } JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + ".\n" + ex.getMessage(), Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE); throw new SaveException("rt"); } finally { frame.unblock(); } boolean commit = true; if (!session.getWriter().couldEncodeAll()) { FormBuilder builder = FormBuilder.create() .layout(new FormLayout("left:pref, 4dlu, fill:pref", "pref, 4dlu, pref")); JTextArea ta = new JTextArea(session.getWriter().getProblemCharacters()); ta.setEditable(false); builder.add(Localization.lang("The chosen encoding '%0' could not encode the following characters:", session.getEncoding().displayName())).xy(1, 1); builder.add(ta).xy(3, 1); builder.add(Localization.lang("What do you want to do?")).xy(1, 3); String tryDiff = Localization.lang("Try different encoding"); int answer = JOptionPane.showOptionDialog(frame, builder.getPanel(), Localization.lang("Save database"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[] { Localization.lang("Save"), tryDiff, Localization.lang("Cancel") }, tryDiff); if (answer == JOptionPane.NO_OPTION) { // The user wants to use another encoding. Object choice = JOptionPane.showInputDialog(frame, Localization.lang("Select encoding"), Localization.lang("Save database"), JOptionPane.QUESTION_MESSAGE, null, Encodings.ENCODINGS_DISPLAYNAMES, encoding); if (choice == null) { commit = false; } else { Charset newEncoding = Charset.forName((String) choice); return saveDatabase(file, selectedOnly, newEncoding); } } else if (answer == JOptionPane.CANCEL_OPTION) { commit = false; } } try { if (commit) { session.commit(file.toPath()); panel.getBibDatabaseContext().getMetaData().setEncoding(encoding); // Make sure to remember which encoding we used. } else { session.cancel(); } } catch (SaveException e) { int ans = JOptionPane.showConfirmDialog(null, Localization.lang("Save failed during backup creation") + ". " + Localization.lang("Save without backup?"), Localization.lang("Unable to create backup"), JOptionPane.YES_NO_OPTION); if (ans == JOptionPane.YES_OPTION) { session.setUseBackup(false); session.commit(file.toPath()); panel.getBibDatabaseContext().getMetaData().setEncoding(encoding); } else { commit = false; } } return commit; }
From source file:com.smanempat.controller.ControllerClassification.java
public String[] processMining(JTextField textNumberOfK, JTable tablePreview, JLabel labelPesanError, JTable tableResult, JLabel labelSiswaIPA, JLabel labelSiswaIPS, JLabel labelKeterangan, JYearChooser jYearChooser1, JYearChooser jYearChooser2, JTabbedPane jTabbedPane1) { String numberValidate = textNumberOfK.getText(); ModelClassification modelClassification = new ModelClassification(); int rowCountModel = modelClassification.getRowCount(); int rowCountData = tablePreview.getRowCount(); System.out.println("Row Count Data : " + rowCountData); System.out.println("Row Count Model : " + rowCountModel); String[] knnValue = null;/*w w w .jav a 2s . c om*/ /*Validasi Nilai Number of Nearest Neighbor*/ if (Pattern.matches("[0-9]+", numberValidate) == false && numberValidate.length() > 0) { labelPesanError.setText("Number of Nearest Neighbor tidak valid"); JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak valid!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png")); textNumberOfK.requestFocus(); } else if (numberValidate.isEmpty()) { JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak boleh kosong!", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png")); labelPesanError.setText("Number of Nearest Neighbor tidak boleh kosong"); textNumberOfK.requestFocus(); } else if (Integer.parseInt(numberValidate) >= rowCountModel) { labelPesanError.setText("Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + ""); JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + " !", "Error", JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png")); textNumberOfK.requestFocus(); } else { int confirm = 0; confirm = JOptionPane.showOptionDialog(null, "Yakin ingin memproses data?", "Proses Klasifikasi", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (confirm == JOptionPane.OK_OPTION) { int kValue = Integer.parseInt(textNumberOfK.getText()); String[][] modelValue = getModelValue(rowCountModel); double[][] dataValue = getDataValue(rowCountData, tablePreview); knnValue = getKNNValue(rowCountData, rowCountModel, modelValue, dataValue, kValue); showClassificationResult(tableResult, tablePreview, knnValue, rowCountData, labelSiswaIPA, labelSiswaIPS, labelKeterangan, jYearChooser1, jYearChooser2, kValue); jTabbedPane1.setSelectedIndex(1); } } return knnValue; }