List of usage examples for javax.swing JOptionPane YES_OPTION
int YES_OPTION
To view the source code for javax.swing JOptionPane YES_OPTION.
Click Source Link
From source file:it.txt.access.capability.demo.soap.client.view.ClientGUIController.java
@Override public void windowClosing(WindowEvent e) { if (clientGUI.getReturnCode() == ClientGUI.FINISH_RETURN_CODE) { stopClientAndCloseApplication(); } else {//from w w w . java2s. c om int resp = JOptionPane.showConfirmDialog(clientGUI, "Are you sure you want to close?"); if (resp == JOptionPane.YES_OPTION) { stopClientAndCloseApplication(); } } }
From source file:gtu._work.etc.EnglishAdd.java
void setDefaultSave() { this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); this.addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent e) { }/*from w w w. j ava2 s . c om*/ public void windowClosing(WindowEvent e) { if (JOptionPane.showConfirmDialog(null, "?") == JOptionPane.YES_OPTION) { String words = wordTextArea.getText(); if (StringUtils.isNotBlank(words) && currentFile != null) { FileUtil.saveToFile(currentFile, words, "BIG5"); } gtu.swing.util.JFrameUtil.setVisible(false, EnglishAdd.this); EnglishAdd.this.dispose(); } } }); }
From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java
private void saveTSV() { JFileChooser chooser = new JFileChooser("Save evaluation result as TSV"); chooser.setCurrentDirectory(frame.defaultDirectory); int returnVal = chooser.showSaveDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { if (chooser.getSelectedFile().exists() && (JOptionPane.showConfirmDialog(frame, "File already exists. Overwrite?") != JOptionPane.YES_OPTION)) { return; }/*from ww w . ja v a 2 s . co m*/ frame.saveTSV(chooser.getSelectedFile()); } }
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/* ww w . jav a 2 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.mirth.connect.plugins.datapruner.DataPrunerPanel.java
public void doStart() { final MutableBoolean saveChanges = new MutableBoolean(false); if (isSaveEnabled()) { if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(this, "Settings changes must be saved first, would you like to save the settings and prune now?", "Select an Option", JOptionPane.OK_CANCEL_OPTION)) { if (!validateFields()) { return; }// w w w.jav a2 s . co m saveChanges.setValue(true); } else { return; } } setStartTaskVisible(false); final String workingId = parent.startWorking("Starting the data pruner..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() { if (saveChanges.getValue()) { try { plugin.setPropertiesToServer(getProperties()); } catch (Exception e) { getFrame().alertThrowable(getFrame(), e); return null; } } try { parent.mirthClient.getServlet(DataPrunerServletInterface.class).start(); } catch (Exception e) { parent.alertThrowable(parent, e, "An error occurred while attempting to start the data pruner."); return null; } return null; } @Override public void done() { if (saveChanges.getValue()) { setSaveEnabled(false); } parent.stopWorking(workingId); updateStatus(); } }; worker.execute(); }
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 w w .j a va 2 s. co m*/ return; } } }
From source file:burlov.ultracipher.swing.SwingGuiApplication.java
public boolean canExit() { if (hasChanges) { /*/*from w ww. j a va 2s . c o m*/ * Wenn es ungespeicherte Aenderungen gibt, dann Benutzer fragen */ int ret = JOptionPane.showConfirmDialog(getMainFrame(), "Save changes before exit?", "", JOptionPane.YES_NO_CANCEL_OPTION); switch (ret) { case JOptionPane.CANCEL_OPTION: return false; case JOptionPane.NO_OPTION: return true; case JOptionPane.YES_OPTION: /* * Speichern anstossen */ saveDatabase(); /* * Nur wenn Speichern erfolgreich war 'true' zurueckgeben */ return !hasChanges; default: return false; } } else { return true; } }
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 av a2 s. c om 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:edu.ku.brc.specify.tools.schemalocale.SchemaToolsDlg.java
private void chooseImportType() { int rv = UIRegistry.askYesNoLocalized(SL_CHS_IMP, SL_CHS_LOC, getResourceString("SL_CHOOSEIMPMSG"), "SL_CHOOSEIMPMSG_TITLE"); if (rv == JOptionPane.YES_OPTION || rv == JOptionPane.NO_OPTION) { importSchema(rv == JOptionPane.NO_OPTION); }//from w w w .j a va 2s .c om }
From source file:com.floreantpos.config.ui.DatabaseConfigurationView.java
public void actionPerformed(ActionEvent e) { try {/*ww w . ja v a 2 s . c om*/ 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()); } }