List of usage examples for javax.swing JOptionPane YES_NO_OPTION
int YES_NO_OPTION
To view the source code for javax.swing JOptionPane YES_NO_OPTION.
Click Source Link
showConfirmDialog
. From source file:com.enderville.enderinstaller.ui.Installer.java
private void advanceStep() { step++;/*from w ww. j a v a2 s. com*/ switch (step) { case 1: { String msg = InstallScript.preInstallCheck(); if (msg != null) { //TODO maybe a better way to check for collisions // so that non-conflicting installs doesn't raise this warning msg = msg + "\nThe EnderPack is meant to be installed on a fresh minecraft.jar and mods folder.\n" + "Do you wish to continue, and attempt to install on top of the current minecraft?"; int opt = JOptionPane.showConfirmDialog(this, msg, "Installation Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (opt == JOptionPane.NO_OPTION) { setVisible(false); dispose(); } } File extraFolder = new File(InstallerConfig.getExtraModsFolder()); //Check that the extras folder exists and that it has some mods in it. Otherwise, simply start installing if (extraFolder.exists()) { File[] children = extraFolder.listFiles(); if (children != null) { for (File child : children) { if (child.isDirectory()) { buildOptionsPane(); return; } } } //extras folder was empty, or no mod directories (only files) advanceStep(); } else { //extras folder didn't exist. advanceStep(); } return; } case 2: buildInstallingPane(); return; default: LOGGER.error("Advanced too far"); } }
From source file:com.bsoft.baseframe.baseframe_utils.beanUtils.Classgenerator.java
/** * ?/*w w w.j a va2s .c o m*/ * @param msg_code int */ private void showMsg(int msg_code) { String message = ""; boolean flag = false; switch (msg_code) { case 0: flag = true; message = "???"; break; case 1: message = "?????"; break; case 2: message = "??"; break; case 3: message = "XML??"; break; case 4: message = "????"; break; case 5: message = "???"; break; } JOptionPane.showMessageDialog(this, message, "", JOptionPane.WARNING_MESSAGE); if (flag) { int closable = JOptionPane.showConfirmDialog(null, "???\n??", "??", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); if (JOptionPane.YES_OPTION == closable) { System.exit(0); } return; } }
From source file:eu.ggnet.dwoss.receipt.UiUnitSupport.java
private UniqueUnit optionalChangeStock(UniqueUnit uniqueUnit, StockUnit stockUnit, Stock localStock, Window parent, String account) { if (!stockUnit.isInStock()) return uniqueUnit; if (localStock.equals(stockUnit.getStock())) return uniqueUnit; if (stockUnit.isInTransaction()) { JOptionPane.showMessageDialog(parent, "Achtung, Gert ist nicht auf " + localStock.getName() + ",\n" + "aber Gert ist auch auf einer Transaktion.\n" + "Automatische Lagernderung nicht mglich !"); return uniqueUnit; }/*from w w w . j a va2 s .c o m*/ int option = JOptionPane.showConfirmDialog(parent, "Gert steht nicht auf " + localStock.getName() + ", welches als Standort angegeben ist. Gertestandort ndern ?", "Standortabweichung", JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { ComboBoxDialog<Stock> dialog = new ComboBoxDialog<>(parent, lookup(StockAgent.class).findAll(Stock.class).toArray(new Stock[0]), new StockCellRenderer()); dialog.setSelection(localStock); dialog.setVisible(true); if (dialog.isOk()) return unitProcessor.transfer(uniqueUnit, dialog.getSelection().getId(), account); } return uniqueUnit; }
From source file:net.sf.profiler4j.console.Console.java
/** * @return <code>true</code> if a new project was created (the user could have been * cancelled)/*from w w w . java 2s. c o m*/ */ public boolean newProject() { if (client.isConnected()) { int ret = JOptionPane.showConfirmDialog(mainFrame, "Proceed and disconnect?", "New Profiling Project", JOptionPane.YES_NO_OPTION); if (ret == JOptionPane.NO_OPTION) { return false; } } if (checkUnsavedChanges()) { return false; } if (client.isConnected()) { disconnect(); if (client.isConnected()) { return false; } } Project p = new Project(); ProjectDialog d = new ProjectDialog(mainFrame, this); if (d.edit(p)) { this.project = p; return true; } return false; }
From source file:be.ac.ua.comp.scarletnebula.gui.windows.LinkUnlinkWindow.java
private final JPanel getMainPanel() { final JPanel mainPanel = new JPanel(new GridBagLayout()); mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); final ServerList linkedServerList = new ServerList(linkedServerListModel); linkedServerList.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); final JScrollPane linkedServerScrollPane = new JScrollPane(linkedServerList); linkedServerScrollPane/*w ww . ja va2 s . co m*/ .setBorder(BorderFactory.createTitledBorder(new EmptyBorder(5, 20, 20, 20), "Linked Servers")); // Doesn't matter what this is set to, as long as it's the same as the // one for unlinkedServerScrollPane linkedServerScrollPane.setPreferredSize(new Dimension(10, 10)); final GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 0; c.weightx = 0.5; c.weighty = 1.0; mainPanel.add(linkedServerScrollPane, c); final ServerList unlinkedServerList = new ServerList(unlinkedServerListModel); unlinkedServerList.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); final JScrollPane unlinkedServerScrollPane = new JScrollPane(unlinkedServerList); unlinkedServerScrollPane .setBorder(BorderFactory.createTitledBorder(new EmptyBorder(5, 20, 20, 20), "Unlinked Servers")); // Doesn't matter what this is set to, as long as it's the same as the // one for unlinkedServerScrollPane unlinkedServerScrollPane.setPreferredSize(new Dimension(10, 10)); final JPanel middlePanel = new JPanel(); middlePanel.setLayout(new BoxLayout(middlePanel, BoxLayout.Y_AXIS)); middlePanel.add(Box.createVerticalGlue()); final JButton linkSelectionButton = new JButton("<"); final JButton unlinkSelectionButton = new JButton(">"); linkSelectionButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { // Move selection from unlinked to linked list final int selection = unlinkedServerList.getSelectedIndex(); if (selection < 0) { return; } final Server server = unlinkedServerListModel.getVisibleServerAtIndex(selection); unlinkedServerListModel.removeServer(server); linkedServerListModel.addServer(server); } }); unlinkSelectionButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { // Move selection from linked to unlinked list final int selection = linkedServerList.getSelectedIndex(); if (selection < 0) { return; } final int answer = JOptionPane.showOptionDialog(LinkUnlinkWindow.this, "You are about to unlink a server. " + "Unlinking a server will permanently remove \nall data associated with " + "this server, but the server will keep running. " + "\n\nAre you sure you wish to continue?", "Unlink Server", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null); if (answer != JOptionPane.YES_OPTION) { return; } final Server server = linkedServerListModel.getVisibleServerAtIndex(selection); linkedServerListModel.removeServer(server); unlinkedServerListModel.addServer(server); } }); middlePanel.add(unlinkSelectionButton); middlePanel.add(Box.createVerticalStrut(10)); middlePanel.add(linkSelectionButton); middlePanel.add(Box.createVerticalGlue()); c.gridx = 1; c.gridy = 0; c.weightx = 0.0; c.weighty = 0.0; mainPanel.add(middlePanel, c); c.gridx = 2; c.gridy = 0; c.weightx = 0.5; c.weighty = 1.0; mainPanel.add(unlinkedServerScrollPane, c); return mainPanel; }
From source file:com.emental.mindraider.ui.outline.OutlineArchiveJPanel.java
public void actionPerformed(ActionEvent e) { int result = JOptionPane.showConfirmDialog(MindRaider.mainJFrame, "Do you really want to delete this Note?", "Delete Note", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { // determine selected concept parameters int selectedRow = table.getSelectedRow(); if (selectedRow >= 0) { // map the row to the model (column sorters may change it) selectedRow = table.convertRowIndexToModel(selectedRow); if (tableModel.getDiscardedConcepts() != null && tableModel.getDiscardedConcepts().length > selectedRow) { MindRaider.noteCustodian.deleteConcept(MindRaider.profile.getActiveOutlineUri().toString(), tableModel.getDiscardedConcepts()[selectedRow].getUri()); OutlineJPanel.getInstance().refresh(); }/*from w ww . j a va 2 s . c om*/ return; } } }
From source file:net.pms.movieinfo.MovieInfo.java
@Override public JComponent config() { FormLayout layout = new FormLayout( "left:pref, 2dlu, p,2dlu, p,2dlu, p, 2dlu, p, 2dlu, p,2dlu, p,200dlu, pref:grow", //$NON-NLS-1$ "p, 5dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p,0:grow"); //$NON-NLS-1$ PanelBuilder builder = new PanelBuilder(layout); builder.border(Borders.EMPTY);/*from w ww . j a va 2s .c o m*/ builder.opaque(false); CellConstraints cc = new CellConstraints(); JComponent cmp = builder.addSeparator("MOVIE INFO CONFIG", cc.xy(1, 1)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); pluginsField = new JTextField(); pluginsField.setEnabled(false); // Until MovieInfoConfiguration.save() is implemented if (configuration.getPlugins() != null) pluginsField.setText(configuration.getPlugins()); pluginsField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { configuration.setPlugins(pluginsField.getText()); } }); builder.addLabel("Plugins to use (in prioritized order):", cc.xy(1, 3)); builder.add(pluginsField, cc.xyw(3, 3, 12)); maxNumberOfActorsField = new JSpinner(new SpinnerNumberModel()); maxNumberOfActorsField.setEnabled(false); // Until MovieInfoConfiguration.save() is implemented maxNumberOfActorsField.setValue(configuration.getMaxNumberOfActors()); maxNumberOfActorsField.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { configuration.setMaxNumberOfActors((Integer) maxNumberOfActorsField.getValue()); } }); builder.addLabel("Maximum number of actors to display:", cc.xy(1, 5)); builder.add(maxNumberOfActorsField, cc.xy(3, 5)); downloadCoverField = new JCheckBox(); downloadCoverField.setEnabled(false); // Until MovieInfoConfiguration.save() is implemented downloadCoverField.setSelected(configuration.getDownloadCover()); downloadCoverField.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { configuration.setDownloadCover(downloadCoverField.isSelected()); } }); builder.addLabel("Download cover to movie folder:", cc.xy(5, 5)); builder.add(downloadCoverField, cc.xy(7, 5)); displayInfoField = new JTextField(); displayInfoField.setEnabled(false); // Until MovieInfoConfiguration.save() is implemented if (configuration.getDisplayInfo() != null) { displayInfoField.setText(configuration.getDisplayInfoAsString()); } displayInfoField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //TODO: Needs verification logics configuration.setDisplayInfoFromString(displayInfoField.getText()); } }); builder.addLabel("DisplayInfo:", cc.xy(13, 5)); builder.add(displayInfoField, cc.xyw(14, 5, 2)); plotLineLengthField = new JSpinner(new SpinnerNumberModel()); plotLineLengthField.setEnabled(false); // Until MovieInfoConfiguration.save() is implemented plotLineLengthField.setValue(configuration.getPlotLineLength()); plotLineLengthField.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { configuration.setPlotLineLength((Integer) plotLineLengthField.getValue()); } }); builder.addLabel("Plot line length:", cc.xy(9, 5)); builder.add(plotLineLengthField, cc.xy(11, 5)); filterField = new JTextField(); filterField.setEnabled(false); // Until MovieInfoConfiguration.save() is implemented if (configuration.getFilters() != null) { filterField.setText(configuration.getFiltersAsString()); } filterField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //TODO: Needs verification logics configuration.setFiltersFromString(filterField.getText()); } }); ScanPath = new JTextField(); builder.addLabel("Filter:", cc.xy(1, 7)); builder.add(filterField, cc.xyw(3, 7, 12)); builder.addLabel("Scan path:", cc.xy(1, 9)); builder.add(ScanPath, cc.xyw(3, 9, 12)); ScanPath.setText((String) PMS.getConfiguration().getCustomProperty("movieinfo.scan_path")); JButton scan = new JButton("Scan files"); scan.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (mdb != null) { if (!mdb.isScanLibraryRunning()) { int option = JOptionPane.showConfirmDialog(LooksFrame.get(), Messages.getString("FoldTab.3") + Messages.getString("FoldTab.4"), Messages.getString("Dialog.Question"), JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { mdb.scanLibrary(ScanPath.getText()); } } else { int option = JOptionPane.showConfirmDialog(LooksFrame.get(), Messages.getString("FoldTab.10"), Messages.getString("Dialog.Question"), JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { mdb.stopScanLibrary(); } } } } }); builder.add(scan, cc.xy(1, 11)); return builder.getPanel(); }
From source file:com.floreantpos.config.ui.DatabaseConfigurationView.java
public void actionPerformed(ActionEvent e) { try {// w w w . jav a 2s . co m String command = e.getActionCommand(); Database selectedDb = (Database) databaseCombo.getSelectedItem(); String providerName = selectedDb.getProviderName(); String databaseURL = tfServerAddress.getText(); String databasePort = tfServerPort.getText(); String databaseName = tfDatabaseName.getText(); String user = tfUserName.getText(); String pass = new String(tfPassword.getPassword()); String connectionString = selectedDb.getConnectString(databaseURL, databasePort, databaseName); String hibernateDialect = selectedDb.getHibernateDialect(); String driverClass = selectedDb.getHibernateConnectionDriverClass(); if (TEST.equalsIgnoreCase(command)) { Application.getInstance().setSystemInitialized(false); saveConfig(selectedDb, providerName, databaseURL, databasePort, databaseName, user, pass, connectionString, hibernateDialect); try { DatabaseUtil.checkConnection(connectionString, hibernateDialect, driverClass, user, pass); } catch (DatabaseConnectionException e1) { JOptionPane.showMessageDialog(this, Messages.getString("DatabaseConfigurationDialog.32")); //$NON-NLS-1$ return; } JOptionPane.showMessageDialog(POSUtil.getBackOfficeWindow(), Messages.getString("DatabaseConfigurationDialog.31")); //$NON-NLS-1$ } else if (CONFIGURE_DB.equals(command)) { Application.getInstance().setSystemInitialized(false); int i = JOptionPane.showConfirmDialog(POSUtil.getBackOfficeWindow(), Messages.getString("DatabaseConfigurationDialog.33"), //$NON-NLS-1$ Messages.getString("DatabaseConfigurationDialog.34"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$ if (i != JOptionPane.YES_OPTION) { return; } i = JOptionPane.showConfirmDialog(POSUtil.getBackOfficeWindow(), Messages.getString("DatabaseConfigurationView.3"), //$NON-NLS-1$ Messages.getString("DatabaseConfigurationView.4"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$ boolean generateSampleData = false; if (i == JOptionPane.YES_OPTION) generateSampleData = true; saveConfig(selectedDb, providerName, databaseURL, databasePort, databaseName, user, pass, connectionString, hibernateDialect); String connectionString2 = selectedDb.getCreateDbConnectString(databaseURL, databasePort, databaseName); this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); boolean createDatabase = DatabaseUtil.createDatabase(connectionString2, hibernateDialect, driverClass, user, pass, generateSampleData); this.setCursor(Cursor.getDefaultCursor()); if (createDatabase) { //JOptionPane.showMessageDialog(DatabaseConfigurationView.this, Messages.getString("DatabaseConfigurationDialog.35")); //$NON-NLS-1$ JOptionPane.showMessageDialog(POSUtil.getBackOfficeWindow(), "Database created. Default password is 1111.\n\nThe system will now restart."); //$NON-NLS-1$ Main.restart(); } else { JOptionPane.showMessageDialog(POSUtil.getBackOfficeWindow(), Messages.getString("DatabaseConfigurationDialog.36")); //$NON-NLS-1$ } } else if (SAVE.equalsIgnoreCase(command)) { Application.getInstance().setSystemInitialized(false); saveConfig(selectedDb, providerName, databaseURL, databasePort, databaseName, user, pass, connectionString, hibernateDialect); } else if (CANCEL.equalsIgnoreCase(command)) { } } catch (Exception e2) { POSMessageDialog.showMessage(com.floreantpos.util.POSUtil.getBackOfficeWindow(), e2.getMessage()); } }
From source file:net.sf.jhylafax.SendDialog.java
private boolean checkPostScript(String filename) { try {//from w w w .java 2 s . c o m if (!HylaFAXClientHelper.isPostscript(filename)) { if (Dialogs.showConfirmDialog(this, i18n.tr("Do you really want to send the non PostScript file \"{0}\"?", filename), i18n.tr("JHylaFAX - Send non PostScript file"), JOptionPane.YES_NO_OPTION, Settings.CONFIRM_NONPS) == JOptionPane.NO_OPTION) { return false; } } } catch (IOException e) { logger.debug("Error checking for PostScript", e); ErrorDialog.showError(this, i18n.tr("Could not check for PostScript"), i18n.tr("JHylaFAX Error"), e); return false; } return true; }
From source file:net.sf.profiler4j.console.Console.java
public void openProject() { if (client.isConnected()) { int ret = JOptionPane.showConfirmDialog(mainFrame, "Proceed and disconnect?", "Open Profiling Project", JOptionPane.YES_NO_OPTION); if (ret == JOptionPane.NO_OPTION) { return; }/*from w w w . j a v a 2s . c o m*/ } if (checkUnsavedChanges()) { return; } if (client.isConnected()) { disconnect(); if (client.isConnected()) { return; } } JFileChooser fc = new JFileChooser(lastDir); fc.addChoosableFileFilter(projectFilter); if (fc.showOpenDialog(mainFrame) == JFileChooser.APPROVE_OPTION) { File selFile = fc.getSelectedFile(); SAXBuilder builder = new SAXBuilder(); Document doc = null; try { doc = builder.build(selFile); } catch (JDOMException e) { error("XML Error", e); } catch (IOException e) { error("I/O Error", e); } if (doc != null) { Project p = new Project(); Element el = doc.getRootElement(); p.setHostname(el.getChildText("Host")); p.setPort(Integer.parseInt(el.getChildText("Port"))); Element rulesEl = el.getChild("Rules"); p.setAccess(Rule.AccessOption.valueOf(rulesEl.getAttributeValue("access"))); p.setBeanprops(Boolean.parseBoolean(rulesEl.getAttributeValue("beanProps"))); p.getRules().clear(); for (Iterator i = rulesEl.getChildren("Rule").iterator(); i.hasNext();) { Element r = (Element) i.next(); Rule rule = new Rule(r.getText(), Rule.Action.valueOf(r.getAttributeValue("action"))); p.getRules().add(rule); } // Backwards compatible way to read the export pattern // If it is not there, we leave the defaults as they are, // otherwise we set the saved setting. Element export = el.getChild(PROJECT_XML_ELEMENT__EXPORT_PATTERN); if (null != export) { String enabled = export.getAttributeValue(PROJECT_XML_ATTRIBUTE__ENABLED); p.setExportAutomaticallyEnabled(Boolean.valueOf(enabled)); p.setExportPattern(export.getAttributeValue(PROJECT_XML_ATTRIBUTE__PATTERN)); } p.setFile(selFile); p.clearChanged(); this.project = p; lastDir = selFile.getParentFile(); } } }