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:Debrief.Tools.FilterOperations.ShowTimeVariablePlot3.java
private WatchableList getPrimary() { WatchableList res = null;/*ww w . ja va 2s . c om*/ // check we have some tracks selected if (_theTracks != null) { final Object[] opts = new Object[_theTracks.size()]; _theTracks.copyInto(opts); res = (WatchableList) JOptionPane.showInputDialog(null, "Which is the primary track?" + System.getProperty("line.separator") + " (to be used as the subject of calculations)", "Show Time Variable Plot", JOptionPane.QUESTION_MESSAGE, null, opts, null); } else { MWC.GUI.Dialogs.DialogFactory.showMessage("Track Selector", "Please select one or more tracks"); } return res; }
From source file:fi.elfcloud.client.tree.ClusterHierarchyModel.java
private String renameDataItem(String name) { name = (String) JOptionPane.showInputDialog(null, Messages.getString("ClusterHierarchyModel.dialog_rename_dataitem_text_1") + //$NON-NLS-1$ Messages.getString("ClusterHierarchyModel.dialog_rename_dataitem_text_2") + name, //$NON-NLS-1$ Messages.getString("ClusterHierarchyModel.dialog_rename_dataitem_title"), //$NON-NLS-1$ JOptionPane.QUESTION_MESSAGE, null, null, name); return name;/*from ww w.ja v a 2 s.c om*/ }
From source file:edu.ku.brc.specify.dbsupport.TaskSemaphoreMgr.java
/** * @param title/*from ww w . ja v a 2s. c om*/ * @param name * @param scope * @return */ public static boolean askUserToUnlock(final String title, final String name, final SCOPE scope) { SpecifyUser user = AppContextMgr.getInstance().getClassObject(SpecifyUser.class); Discipline discipline = scope == SCOPE.Discipline ? AppContextMgr.getInstance().getClassObject(Discipline.class) : null; Collection collection = scope == SCOPE.Collection ? AppContextMgr.getInstance().getClassObject(Collection.class) : null; DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); SpTaskSemaphore semaphore = null; try { semaphore = getSemaphore(session, name, scope, discipline, collection); } 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) { // can't be unlocked at this time. // or it isn't locked } else { if (!semaphore.getIsLocked() && !(semaphore.getUsageCount() != null && semaphore.getUsageCount() > 0)) { return false; } // Check to see if we have the same user on the same machine. String currMachineName = InetAddress.getLocalHost().toString(); String dbMachineName = semaphore.getMachineName(); if (StringUtils.isNotEmpty(dbMachineName) && StringUtils.isNotEmpty(currMachineName) && currMachineName.equals(dbMachineName) && semaphore.getOwner() != null && user != null && user.getId().equals(semaphore.getOwner().getId())) { // In use by this user int options = JOptionPane.YES_NO_OPTION; Object[] optionLabels = new String[] { getResourceString("SpTaskSemaphore.OVERRIDE"), //$NON-NLS-1$ getResourceString("CANCEL")//$NON-NLS-1$ }; int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), getLocalizedMessage("SpTaskSemaphore.IN_USE_BY_YOU_UNLK", title, title), getResourceString("SpTaskSemaphore.IN_USE_TITLE"), //$NON-NLS-1$ options, JOptionPane.QUESTION_MESSAGE, null, optionLabels, 1); return userChoice == JOptionPane.YES_OPTION; } String userStr = prevLockedBy != null ? prevLockedBy : semaphore.getOwner().getIdentityTitle(); String msg = UIRegistry.getLocalizedMessage("SpTaskSemaphore.IN_USE_OV_UNLK", title, userStr, semaphore.getLockedTime() == null ? "?" : semaphore.getLockedTime().toString()); int options; Object[] optionLabels; options = JOptionPane.YES_NO_OPTION; optionLabels = new String[] { getResourceString("SpTaskSemaphore.OVERRIDE"), //$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, 1); return userChoice == JOptionPane.YES_OPTION; } } 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 false; }
From source file:e3fraud.gui.MainWindow.java
public void actionPerformed(ActionEvent e) { //Handle open button action. if (e.getSource() == openButton) { int returnVal = fc.showOpenDialog(MainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); //parse file this.baseModel = FileParser.parseFile(file); log.append(currentTime.currentTime() + " Opened: " + file.getName() + "." + newline); } else {//from w w w . j a va 2 s. c o m log.append(currentTime.currentTime() + " Open command cancelled by user." + newline); } log.setCaretPosition(log.getDocument().getLength()); //handle Generate button } else if (e.getSource() == generateButton) { if (this.baseModel != null) { //have the user indicate the ToA via pop-up JFrame frame1 = new JFrame("Select Target of Assessment"); Map<String, Resource> actorsMap = this.baseModel.getActorsMap(); String selectedActorString = (String) JOptionPane.showInputDialog(frame1, "Which actor's perspective are you taking?", "Choose main actor", JOptionPane.QUESTION_MESSAGE, null, actorsMap.keySet().toArray(), actorsMap.keySet().toArray()[0]); if (selectedActorString == null) { log.append(currentTime.currentTime() + " Attack generation cancelled!" + newline); } else { lastSelectedActorString = selectedActorString; //have the user select a need via pop-up JFrame frame2 = new JFrame("Select graph parameter"); Map<String, Resource> needsMap = this.baseModel.getNeedsMap(); String selectedNeedString = (String) JOptionPane.showInputDialog(frame2, "What do you want to use as parameter?", "Choose need to parametrize", JOptionPane.QUESTION_MESSAGE, null, needsMap.keySet().toArray(), needsMap.keySet().toArray()[0]); if (selectedNeedString == null) { log.append("Attack generation cancelled!" + newline); } else { lastSelectedNeedString = selectedNeedString; //have the user select occurence interval via pop-up JTextField xField = new JTextField("1", 4); JTextField yField = new JTextField("500", 4); JPanel myPanel = new JPanel(); myPanel.add(new JLabel("Mininum occurences:")); myPanel.add(xField); myPanel.add(Box.createHorizontalStrut(15)); // a spacer myPanel.add(new JLabel("Maximum occurences:")); myPanel.add(yField); int result = JOptionPane.showConfirmDialog(null, myPanel, "Please Enter occurence rate interval", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.CANCEL_OPTION) { log.append("Attack generation cancelled!" + newline); } else if (result == JOptionPane.OK_OPTION) { startValue = Integer.parseInt(xField.getText()); endValue = Integer.parseInt(yField.getText()); selectedNeed = needsMap.get(selectedNeedString); selectedActor = actorsMap.get(selectedActorString); //Have a Worker thread to the time-consuming generation and raking (to not freeze the GUI) GenerationWorker generationWorker = new GenerationWorker(baseModel, selectedActorString, selectedActor, selectedNeed, selectedNeedString, startValue, endValue, log, lossButton, gainButton, lossGainButton, gainLossButton, groupingButton, collusionsButton) { //make it so that when Worker is done @Override protected void done() { try { progressBar.setVisible(false); System.err.println("I made it invisible"); //the Worker's result is retrieved treeModel.setRoot(get()); tree.setModel(treeModel); tree.updateUI(); tree.collapseRow(1); //tree.expandRow(0); tree.setRootVisible(false); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } catch (InterruptedException | ExecutionException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); log.append("Out of memory; please increase heap size of JVM"); PopUps.infoBox( "Encountered an error. Most likely out of memory; try increasing the heap size of JVM", "Error"); } } }; this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); progressBar.setVisible(true); progressBar.setIndeterminate(true); progressBar.setString("generating..."); generationWorker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("phase".equals(evt.getPropertyName())) { progressBar.setMaximum(100); progressBar.setIndeterminate(false); progressBar.setString("ranking..."); } else if ("progress".equals(evt.getPropertyName())) { progressBar.setValue((Integer) evt.getNewValue()); } } }); generationWorker.execute(); } } } } else { log.append("Load a model file first!" + newline); } } //handle the refresh button else if (e.getSource() == refreshButton) { if (lastSelectedNeedString != null && lastSelectedActorString != null) { Map<String, Resource> actorsMap = this.baseModel.getActorsMap(); Map<String, Resource> needsMap = this.baseModel.getNeedsMap(); selectedNeed = needsMap.get(lastSelectedNeedString); selectedActor = actorsMap.get(lastSelectedActorString); //Have a Worker thread to the time-consuming generation and raking (to not freeze the GUI) GenerationWorker generationWorker = new GenerationWorker(baseModel, lastSelectedActorString, selectedActor, selectedNeed, lastSelectedNeedString, startValue, endValue, log, lossButton, gainButton, lossGainButton, gainLossButton, groupingButton, collusionsButton) { //make it so that when Worker is done @Override protected void done() { try { progressBar.setVisible(false); //the Worker's result is retrieved treeModel.setRoot(get()); tree.setModel(treeModel); tree.updateUI(); tree.collapseRow(1); //tree.expandRow(0); tree.setRootVisible(false); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } catch (InterruptedException | ExecutionException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); log.append("Most likely out of memory; please increase heap size of JVM"); PopUps.infoBox( "Encountered an error. Most likely out of memory; try increasing the heap size of JVM", "Error"); } } }; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); progressBar.setVisible(true); progressBar.setIndeterminate(true); progressBar.setString("generating..."); generationWorker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("phase".equals(evt.getPropertyName())) { progressBar.setMaximum(100); progressBar.setIndeterminate(false); progressBar.setString("ranking..."); } else if ("progress".equals(evt.getPropertyName())) { progressBar.setValue((Integer) evt.getNewValue()); } } }); generationWorker.execute(); } else { log.append(currentTime.currentTime() + " Nothing to refresh. Generate models first" + newline); } } //handle show ideal graph button else if (e.getSource() == idealGraphButton) { if (this.baseModel != null) { graph1 = GraphingTool.generateGraph(baseModel, selectedNeed, startValue, endValue, true);//expected graph ChartFrame chartframe1 = new ChartFrame("Ideal results", graph1); chartframe1.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT)); chartframe1.pack(); chartframe1.setLocationByPlatform(true); chartframe1.setVisible(true); } else { log.append(currentTime.currentTime() + " Load a model file first!" + newline); } } //Handle the graph extend button//Handle the graph extend button else if (e.getSource() == expandButton) { //make sure there is a graph to show if (graph2 == null) { log.append(currentTime.currentTime() + " No graph to display. Select one first." + newline); } else { //this makes sure both graphs have the same y axis: // double lowerBound = min(graph1.getXYPlot().getRangeAxis().getRange().getLowerBound(), graph2.getXYPlot().getRangeAxis().getRange().getLowerBound()); // double upperBound = max(graph1.getXYPlot().getRangeAxis().getRange().getUpperBound(), graph2.getXYPlot().getRangeAxis().getRange().getUpperBound()); // graph1.getXYPlot().getRangeAxis().setRange(lowerBound, upperBound); // graph2.getXYPlot().getRangeAxis().setRange(lowerBound, upperBound); chartPane.removeAll(); chartPanel = new ChartPanel(graph2); chartPanel.setPreferredSize(new Dimension(CHART_WIDTH, CHART_HEIGHT)); chartPane.add(chartPanel); chartPane.add(collapseButton); extended = true; this.setPreferredSize(new Dimension(this.getWidth() + CHART_WIDTH, this.getHeight())); JFrame frame = (JFrame) getRootPane().getParent(); frame.pack(); } } //Handle the graph collapse button//Handle the graph collapse button else if (e.getSource() == collapseButton) { System.out.println("resizing by -" + CHART_WIDTH); chartPane.removeAll(); chartPane.add(expandButton); this.setPreferredSize(new Dimension(this.getWidth() - CHART_WIDTH, this.getHeight())); chartPane.repaint(); chartPane.revalidate(); extended = false; JFrame frame = (JFrame) getRootPane().getParent(); frame.pack(); } }
From source file:Debrief.Tools.FilterOperations.ShowTimeVariablePlot3.java
private CalculationHolder getChoice() { final Object[] opts = new Object[_theOperations.size()]; _theOperations.copyInto(opts);//from w ww. j a va 2 s .c om final CalculationHolder res = (CalculationHolder) JOptionPane.showInputDialog(null, "Which operation?", "Plot time variables", JOptionPane.QUESTION_MESSAGE, null, opts, null); return res; }
From source file:carolina.pegaLatLong.LatLong.java
private void btnGerarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGerarActionPerformed // TODO add your handling code here: List<JRadioButton> radios = new ArrayList<>(); JPanel painel = new JPanel(); JRadioButton btnEncontrados = new JRadioButton("Encontrados \n"); JRadioButton btnNaoEncontrados = new JRadioButton("No encontrados"); JRadioButton btnEncontradosMais = new JRadioButton("Mais de um encontrados"); JRadioButton btnTudo = new JRadioButton("Tudo"); ButtonGroup btnGroup = new ButtonGroup(); btnGroup.add(btnTudo);/*from w ww. j a v a 2 s.c o m*/ btnGroup.add(btnEncontrados); btnGroup.add(btnNaoEncontrados); btnGroup.add(btnEncontradosMais); //painel.add(btnTudo); painel.add(btnEncontrados); painel.add(btnNaoEncontrados); painel.add(btnEncontradosMais); JOptionPane.showMessageDialog(null, painel, "Escolha uma opo:", JOptionPane.QUESTION_MESSAGE); if (btnTudo.isSelected()) { System.err.println("Tudo selecionado!"); } else if (btnNaoEncontrados.isSelected()) { System.err.println("No encontrados!"); } else if (btnEncontrados.isSelected()) { try { geraCsv(listaResultado); } catch (IOException ex) { Logger.getLogger(LatLong.class.getName()).log(Level.SEVERE, null, ex); } } else if (btnEncontradosMais.isSelected()) { System.err.println("Encontrados mais"); } }
From source file:fur.shadowdrake.minecraft.InstallPanel.java
@Deprecated private boolean registerRhaokarLightPack(File path) throws NetworkException { FileOutputStream fos;/*from w w w . j a va 2 s. c o m*/ try { fos = new FileOutputStream(new File(path, "modpack")); fos.write("rhaokar_light".getBytes()); fos.close(); } catch (FileNotFoundException ex) { return false; } catch (IOException ex) { return false; } if (new File(path, "resourcepacks/01.zip").isFile()) { downloadFile("manifest.json"); } else if (new File(path, "resourcepacks/Soatex_Custom.zip").isFile()) { try { EventQueue.invokeAndWait(() -> { result = JOptionPane.showConfirmDialog(InstallPanel.this, "An old version of the graphics pack was detected. Do you want to keep it?\nIf you choose no, your selection in addons will be downloaded.", "Addons", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); }); } catch (InterruptedException | InvocationTargetException ex) { Logger.getLogger(InstallPanel.class.getName()).log(Level.SEVERE, null, ex); } switch (result) { case JOptionPane.YES_OPTION: downloadFile("manifest_old.json", "manifest.json"); break; default: new File(path, "mods/ShadersModCore-v2.3.31-mc1.7.10-f.jar").delete(); try { cleanDirectory(new File(path, "resourcepacks")); } catch (IOException ex) { } try { deleteDirectory(new File(path, "shaderpacks")); } catch (IOException ex) { } downloadAddons(); } } return true; }
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;/* ww w. ja v a2 s.c o m*/ } 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:marytts.tools.voiceimport.DatabaseImportMain.java
protected void askIfSave() throws IOException { if (bnl.hasChanged()) { int answer = JOptionPane.showOptionDialog(this, "Do you want to save the list of basenames?", "Save?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (answer == JOptionPane.YES_OPTION) { JFileChooser fc = new JFileChooser(); fc.setSelectedFile(new File(db.getProp(db.BASENAMEFILE))); int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { bnl.write(fc.getSelectedFile()); }/*w ww .j a va2s . c om*/ } } else { System.exit(0); } }
From source file:Import.pnl_import_vcf.java
private void btn_importActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_importActionPerformed // TODO add your handling code here: String[] singleColumns = singleColumns(); String[] selectedFamilies = selectedFamilies(); CheckBoxList checkList = new CheckBoxList(); DefaultListModel model = new DefaultListModel(); for (String a : singleColumns) { model.addElement(a);//from w w w. j a v a2 s. co m } checkList.setModel(model); String filePath = filePathField.getText(); if (rbt_existing_tbl.isSelected()) { try { String[] selectedTableFamilies = tableFamilies(); JTable tableMap = new JTable(); DefaultTableModel tableMapModel = (DefaultTableModel) tableMap.getModel(); setMapTable(tableMap, tableMapModel, selectedFamilies, selectedTableFamilies); int map = JOptionPane.showConfirmDialog(null, tableMap, "Please map to column", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null); if (map == 2) { return; } Object[] o = getMapPair(tableMapModel); String selectTableName = tbl_hbase_tables.getValueAt(tbl_hbase_tables.getSelectedRow(), 0) .toString(); String[] mappedFamilies = (String[]) o[1]; String[] mappedTableFamilies = (String[]) o[0]; String[] keys = getKey(selectTableName); importToTable.importDataJob importData = new importDataJob(); importData.importData(filePath, selectTableName, mappedTableFamilies, mappedFamilies, keys); } catch (Exception ex) { Logger.getLogger(pnl_import_vcf.class.getName()).log(Level.SEVERE, null, ex); } } else { try { int key = JOptionPane.showConfirmDialog(null, checkList, "Please choose Key", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null); if (key == 2) { return; } Object[] selectedKey = checkList.getCheckBoxListSelectedValues(); File f = new File(filePath); String fname = f.getName(); String tableName = FilenameUtils.removeExtension(fname); writeKey(selectedKey, tableName); writeType(tableName); createColumnsTxt(tableName); ArrayList<String> list = new ArrayList<>(); for (Object o : selectedKey) { list.add(o.toString()); } String[] keys = list.toArray(new String[list.size()]); importToNewTable.createDataJob importData = new createDataJob(); importData.importData(filePath, selectedFamilies, keys); } catch (Exception ex) { Logger.getLogger(pnl_import_vcf.class.getName()).log(Level.SEVERE, null, ex); } } filePathField.setText(null); DefaultDualListModel dualModel = new DefaultDualListModel(); list_dual_hbase_column_family.setModel(dualModel); pnl_import_vcf.showHBaseTables runabletask = new pnl_import_vcf.showHBaseTables(); new Thread(runabletask).start(); }