List of usage examples for javax.swing JOptionPane OK_OPTION
int OK_OPTION
To view the source code for javax.swing JOptionPane OK_OPTION.
Click Source Link
From source file:de.mycrobase.jcloudapp.Main.java
private static Map<String, String> showLoginDialog() { String message = ""; //"Welcome to JCloudApp!"; JTextField usernameField = new JTextField(); JPasswordField passwordField = new JPasswordField(); JCheckBox remeberCheck = new JCheckBox("Remember login (on disk)"); remeberCheck.setSelected(true);//from w ww . jav a2s.c om Object[] content = { message, "Username:", usernameField, "Password:", passwordField, remeberCheck }; // int res = JOptionPane.showOptionDialog( // null, content, "JCloudApp - Login", // JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, icon, // null, usernameField); int res = JOptionPane.showConfirmDialog(null, content, "JCloudApp - Login", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, IconLarge); if (res == JOptionPane.OK_OPTION) { HashMap<String, String> m = new HashMap<String, String>(); m.put("username", usernameField.getText()); m.put("password", new String(passwordField.getPassword())); m.put("remember", Boolean.toString(remeberCheck.isSelected())); return m; } else { return null; } }
From source file:gui.DownloadPanel.java
public void actionReDownload() { int action = JOptionPane.showConfirmDialog(parent, "Do you realy want to redownload the file?", "Confirm Redownload", JOptionPane.OK_CANCEL_OPTION); if (action == JOptionPane.OK_OPTION) { Download newDownload = selectedDownload; try {/*from w ww.ja va 2 s. com*/ FileUtils.forceDelete(new File(selectedDownload.getDownloadRangePath() + File.separator + selectedDownload.getDownloadName())); // todo must again } catch (IOException e) { e.printStackTrace(); } if (newDownload.getStatus() == DownloadStatus.COMPLETE) { newDownload.resetData(); newDownload.resume(); tableSelectionChanged(); } } }
From source file:edu.ku.brc.specify.dbsupport.TaskSemaphoreMgr.java
/** * Locks the semaphore./* w w w . j av a 2s.c o m*/ * @param title The human (localized) title of the task * @param name the unique name * @param context * @param scope the scope of the lock * @param allViewMode allows it to ask the user about 'View Only' * @return */ public static USER_ACTION lock(final String title, final String name, final String context, final SCOPE scope, final boolean allViewMode, final TaskSemaphoreMgrCallerIFace caller, final boolean checkUsage) { DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); int count = 0; do { SpTaskSemaphore semaphore = null; try { semaphore = setLock(session, name, context, scope, true, false, checkUsage); } catch (StaleObjectException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(TaskSemaphoreMgr.class, ex); semaphore = null; } if (semaphore == null || previouslyLocked) { if (caller != null) { return caller.resolveConflict(semaphore, previouslyLocked, prevLockedBy); } if (semaphore == null) { String msg = UIRegistry.getLocalizedMessage("SpTaskSemaphore.IN_USE", title);//$NON-NLS-1$ Object[] options = { getResourceString("SpTaskSemaphore.TRYAGAIN"), //$NON-NLS-1$ getResourceString("CANCEL") //$NON-NLS-1$ }; int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), msg, getResourceString("SpTaskSemaphore.IN_USE_TITLE"), //$NON-NLS-1$ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (userChoice == JOptionPane.NO_OPTION) { return USER_ACTION.Cancel; } } else { // Check to see if we have the same user on the same machine. SpecifyUser user = AppContextMgr.getInstance().getClassObject(SpecifyUser.class); String currMachineName = InetAddress.getLocalHost().toString(); String dbMachineName = semaphore.getMachineName(); //System.err.println("["+dbMachineName+"]["+currMachineName+"]["+user.getId()+"]["+semaphore.getOwner().getId()+"]"); if (StringUtils.isNotEmpty(dbMachineName) && StringUtils.isNotEmpty(currMachineName) && currMachineName.equals(dbMachineName) && semaphore.getOwner() != null && user != null && user.getId().equals(semaphore.getOwner().getId())) { if (allViewMode) { int options = JOptionPane.YES_NO_OPTION; Object[] optionLabels = new String[] { getResourceString("SpTaskSemaphore.VIEWMODE"), //$NON-NLS-1$ getResourceString("CANCEL")//$NON-NLS-1$ }; int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), getLocalizedMessage("SpTaskSemaphore.IN_USE_BY_YOU", title), getResourceString("SpTaskSemaphore.IN_USE_TITLE"), //$NON-NLS-1$ options, JOptionPane.QUESTION_MESSAGE, null, optionLabels, 0); return userChoice == JOptionPane.NO_OPTION ? USER_ACTION.Cancel : USER_ACTION.ViewMode; // CHECKED } int options = JOptionPane.OK_OPTION; Object[] optionLabels = new String[] { getResourceString("OK")//$NON-NLS-1$ }; JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), getLocalizedMessage("SpTaskSemaphore.IN_USE_BY_YOU", title), getResourceString("SpTaskSemaphore.IN_USE_TITLE"), //$NON-NLS-1$ options, JOptionPane.QUESTION_MESSAGE, null, optionLabels, 0); return USER_ACTION.Cancel; } String userStr = prevLockedBy != null ? prevLockedBy : semaphore.getOwner().getIdentityTitle(); String msgKey = allViewMode ? "SpTaskSemaphore.IN_USE_OV" : "SpTaskSemaphore.IN_USE"; String msg = UIRegistry.getLocalizedMessage(msgKey, title, userStr, semaphore.getLockedTime() != null ? semaphore.getLockedTime().toString() : ""); int options; int defBtn; Object[] optionLabels; if (allViewMode) { defBtn = 2; options = JOptionPane.YES_NO_CANCEL_OPTION; optionLabels = new String[] { getResourceString("SpTaskSemaphore.VIEWMODE"), //$NON-NLS-1$ getResourceString("SpTaskSemaphore.TRYAGAIN"), //$NON-NLS-1$ getResourceString("CANCEL")//$NON-NLS-1$ }; } else { defBtn = 0; options = JOptionPane.YES_NO_OPTION; optionLabels = new String[] { getResourceString("SpTaskSemaphore.TRYAGAIN"), //$NON-NLS-1$ getResourceString("CANCEL"), //$NON-NLS-1$ }; } int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), msg, getResourceString("SpTaskSemaphore.IN_USE_TITLE"), //$NON-NLS-1$ options, JOptionPane.QUESTION_MESSAGE, null, optionLabels, defBtn); if (userChoice == JOptionPane.YES_OPTION) { if (options == JOptionPane.YES_NO_CANCEL_OPTION) { return USER_ACTION.ViewMode; // CHECKED } // this means try again } else if (userChoice == JOptionPane.NO_OPTION) { if (options == JOptionPane.YES_NO_OPTION) { return USER_ACTION.Cancel; } // CHECKED } else if (userChoice == JOptionPane.CANCEL_OPTION) { return USER_ACTION.Cancel; // CHECKED } } } else { return USER_ACTION.OK; } count++; } while (true); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(TaskSemaphoreMgr.class, ex); ex.printStackTrace(); //log.error(ex); } finally { if (session != null) { session.close(); } } return USER_ACTION.Error; }
From source file:org.gumtree.vis.plot1d.Plot1DPanel.java
private void showPropertyEditor(int tabIndex) { XYDataset dataset = getChart().getXYPlot().getDataset(); if (selectedSeriesIndex >= 0 && selectedSeriesIndex < dataset.getSeriesCount()) { Plot1DChartEditor.setSuggestedSeriesKey((String) dataset.getSeriesKey(selectedSeriesIndex)); }/* w w w .j a v a 2s.c o m*/ Plot1DChartEditor editor = new Plot1DChartEditor(getChart(), this); editor.getTabs().setSelectedIndex(tabIndex); int result = JOptionPane.showConfirmDialog(this, editor, localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { editor.updateChart(getChart()); } }
From source file:be.nbb.demetra.dfm.output.simulation.RMSEGraphView.java
private void filterButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filterButtonActionPerformed int r = JOptionPane.showConfirmDialog(chartPanel, filterPanel, "Select evaluation sample", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (r == JOptionPane.OK_OPTION) { updateChart();/* ww w .ja v a2 s .com*/ } }
From source file:SuitaDetails.java
private void showLib() { JScrollPane jScrollPane1 = new JScrollPane(); JList jList1 = new JList(); JPanel libraries = new JPanel(); jScrollPane1.setViewportView(jList1); GroupLayout layout = new GroupLayout(libraries); libraries.setLayout(layout);/*from w w w .java 2 s . com*/ layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)); try { Object[] s = (Object[]) RunnerRepository.getRPCClient().execute("getLibrariesList", new Object[] { RunnerRepository.user }); String[] libs = new String[s.length]; for (int i = 0; i < s.length; i++) { libs[i] = s[i].toString(); } ArrayList<Integer> ind = new ArrayList<Integer>(); jList1.setModel(new DefaultComboBoxModel(libs)); for (String st : globallib) { for (int i = 0; i < libs.length; i++) { if (libs[i].equals(st)) { ind.add(new Integer(i)); } } } int[] indices = new int[ind.size()]; for (int i = 0; i < ind.size(); i++) { indices[i] = ind.get(i); } jList1.setSelectedIndices(indices); } catch (Exception e) { System.out.println("There was an error on calling getLibrariesList on CE"); e.printStackTrace(); } int resp = (Integer) CustomDialog.showDialog(libraries, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, RunnerRepository.window, "Libraries", null); if (resp == JOptionPane.OK_OPTION) { Object[] val = jList1.getSelectedValues(); globallib = new String[val.length]; for (int s = 0; s < val.length; s++) { globallib[s] = val[s].toString(); } } }
From source file:sk.uniza.fri.pds.spotreba.energie.gui.MainGui.java
private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed final ZamestnanecRegionParams params = new ZamestnanecRegionParams(); int option = showUniversalInputDialog(params, "Zamestnanci v regine"); if (option == JOptionPane.OK_OPTION) { new SwingWorker<List, RuntimeException>() { @Override//from w w w. j a v a 2 s . c o m protected List doInBackground() throws Exception { try { return SeZamestnanecService.getInstance().findInRegion(params); } catch (RuntimeException e) { publish(e); return null; } } @Override protected void done() { try { List data = get(); showJTable(SeZamestnanecInfo.class, data); } catch (InterruptedException | ExecutionException ex) { Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex); } } @Override protected void process(List<RuntimeException> chunks) { if (chunks.size() > 0) { showException("Chyba", chunks.get(0)); } } }.execute(); } }
From source file:com.mgmtp.perfload.loadprofiles.ui.dialog.SettingsDialog.java
private void deleteConfigFile() { if (JOptionPane.showConfirmDialog(null, "Delete settings?", "Confirmation", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { int index = cboConfigurationFile.getSelectedIndex(); String fileName = (String) cboConfigurationFile.getSelectedItem(); configFiles.remove(fileName);/*from w w w. j av a2 s. c om*/ index--; if (index < 0 && !configFiles.isEmpty()) { index = 0; } cboConfigurationFile.setSelectedIndex(index); if (configFiles.isEmpty()) { operations.clear(); targets.clear(); clients.clear(); dirty = false; } controller.deleteSettingsFile(fileName); } }
From source file:com.sshtools.common.vomanagementtool.common.VOHelper.java
public static boolean createVOMSLOCATIONDialog() { boolean isSuccessful = false; VOMSLocationPanel vomsPanel = new VOMSLocationPanel(); int result = JOptionPane.showConfirmDialog(null, vomsPanel, "VOMS Location", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, new ResourceIcon(vomsPanel.getClass(), ConfigHelper.ICON)); if (result == JOptionPane.OK_OPTION) { if (vomsPanel.getVOMSLocation() != null && !vomsPanel.getVOMSLocation().equals("")) { vomslocation = vomsPanel.getVOMSLocation(); refreshVOMSConfig();//w ww .j a v a 2 s. c o m PreferencesStore.put(SshTerminalPanel.PREF_VOMS_LOCATION, vomslocation); } } return isSuccessful; }
From source file:com.opendoorlogistics.studio.appframe.AppFrame.java
@Override public boolean canCloseDatastore() { if (loaded == null) { return true; }/*from w w w. j a va 2 s . com*/ // if (loaded.isModified()) { if (datastoreCloseNeedsUseConfirmation) { if (JOptionPane.showConfirmDialog(this, "Any unsaved work will be lost. Do you want to exit?", "Confirm exit", JOptionPane.OK_CANCEL_OPTION) != JOptionPane.OK_OPTION) { return false; } } // } return true; }