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:edu.clemson.cs.nestbed.client.gui.TestbedManagerFrame.java
private boolean confirmDelete(String text) { int choice;/*from ww w . j a v a 2 s . c o m*/ choice = JOptionPane.showConfirmDialog(this, "Do you wisth to delete '" + text + "'?", "Delete Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); return (choice == JOptionPane.YES_OPTION); }
From source file:AltiConsole.AltiConsoleMainScreen.java
/** * Handles all the actions./*from w w w. j av a 2 s . c o m*/ * * @param e * the action event. */ public void actionPerformed(final ActionEvent e) { final Translator trans = Application.getTranslator(); if (e.getActionCommand().equals("EXIT")) { System.out.println("exit and disconnecting\n"); if (JOptionPane.showConfirmDialog(this, trans.get("AltiConsoleMainScreen.ClosingWindow"), trans.get("AltiConsoleMainScreen.ReallyClosing"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { DisconnectFromAlti(); System.exit(0); } } else if (e.getActionCommand().equals("ABOUT")) { AboutDialog.showPreferences(AltiConsoleMainScreen.this); } // ERASE_FLIGHT else if (e.getActionCommand().equals("ERASE_FLIGHT")) { if (JOptionPane.showConfirmDialog(this, trans.get("AltiConsoleMainScreen.eraseAllflightData"), trans.get("AltiConsoleMainScreen.eraseAllflightDataTitle"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { System.out.println("erasing flight\n"); ErasingFlight(); } } else if (e.getActionCommand().equals("RETRIEVE_FLIGHT")) { System.out.println("retrieving flight\n"); RetrievingFlight(); } else // SAVE_FLIGHT if (e.getActionCommand().equals("SAVE_FLIGHT")) { System.out.println("Saving current flight\n"); SavingFlight(); } else // RETRIEVE_ALTI_CFG if (e.getActionCommand().equals("RETRIEVE_ALTI_CFG")) { System.out.println("retrieving alti config\n"); AltiConfigData pAlticonfig = retrieveAltiConfig(); if (pAlticonfig != null) AltiConfigDlg.showPreferences(AltiConsoleMainScreen.this, pAlticonfig, Serial); } // LICENSE else if (e.getActionCommand().equals("LICENSE")) { LicenseDialog.showPreferences(AltiConsoleMainScreen.this); } // comPorts else if (e.getActionCommand().equals("comPorts")) { DisconnectFromAlti(); String currentPort; //e. currentPort = (String) comPorts.getSelectedItem(); if (Serial != null) Serial.searchForPorts(); System.out.println("We have a new selected value for comport\n"); comPorts.setSelectedItem(currentPort); } // UPLOAD_FIRMWARE else if (e.getActionCommand().equals("UPLOAD_FIRMWARE")) { System.out.println("upload firmware\n"); //make sure to disconnect first DisconnectFromAlti(); JFileChooser fc = new JFileChooser(); String hexfile = null; File startFile = new File(System.getProperty("user.dir")); //FileNameExtensionFilter filter; fc.setDialogTitle("Select firmware"); //fc.set fc.setCurrentDirectory(startFile); //fc.addChoosableFileFilter(new FileNameExtensionFilter("*.HEX", "hex")); fc.setFileFilter(new FileNameExtensionFilter("*.hex", "hex")); //fc.fil int action = fc.showOpenDialog(SwingUtilities.windowForComponent(this)); if (action == JFileChooser.APPROVE_OPTION) { hexfile = fc.getSelectedFile().getAbsolutePath(); } if (hexfile != null) { String exefile = UserPref.getAvrdudePath(); String conffile = UserPref.getAvrdudeConfigPath(); String opts = " -v -v -v -v -patmega328p -carduino -P\\\\.\\" + (String) this.comPorts.getSelectedItem() + " -b115200 -D -V "; String cmd = exefile + " -C" + conffile + opts + " -Uflash:w:" + hexfile + ":i"; System.out.println(cmd); try { Process p = Runtime.getRuntime().exec(cmd); AfficheurFlux fluxSortie = new AfficheurFlux(p.getInputStream(), this); AfficheurFlux fluxErreur = new AfficheurFlux(p.getErrorStream(), this); new Thread(fluxSortie).start(); new Thread(fluxErreur).start(); p.waitFor(); } catch (IOException e1) { e1.printStackTrace(); } catch (InterruptedException e2) { e2.printStackTrace(); } } } // ON_LINE_HELP else if (e.getActionCommand().equals("ON_LINE_HELP")) { Desktop d = Desktop.getDesktop(); System.out.println("Online help \n"); try { d.browse(new URI(trans.get("help.url"))); } catch (URISyntaxException e1) { System.out.println("Illegal URL: " + trans.get("help.url") + " " + e1.getMessage()); } catch (IOException e1) { System.out.println("Unable to launch browser: " + e1.getMessage()); } } }
From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterEditorDlg.java
@Override protected void okButtonPressed() { if (fieldsPanel.getEditBtn().isEnabled()) { int userChoice = JOptionPane.NO_OPTION; Object[] options = { getResourceString("Continue"), //$NON-NLS-1$ getResourceString("CANCEL") //$NON-NLS-1$ };// www . j a va 2 s . c om loadAndPushResourceBundle("masterusrpwd"); userChoice = JOptionPane.showOptionDialog(this, getResourceString("UIFEDlg.ITEM_CHG"), //$NON-NLS-1$ getResourceString("UIFEDlg.CHG_TITLE"), //$NON-NLS-1$ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (userChoice == JOptionPane.NO_OPTION) { return; } } super.okButtonPressed(); getDataFromUI(); }
From source file:gdt.jgui.entity.folder.JFolderPanel.java
/** * Get the context menu./* w w w . j av a2s.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) { //System.out.println("EntitiesPanel:getConextMenu:menu selected"); menu.removeAll(); if (mia != null) { for (JMenuItem mi : mia) menu.add(mi); menu.addSeparator(); } JMenuItem refreshItem = new JMenuItem("Refresh"); refreshItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JConsoleHandler.execute(console, locator$); } }); menu.add(refreshItem); JMenuItem openItem = new JMenuItem("Open folder"); openItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { File folder = new File(entihome$ + "/" + entityKey$); if (!folder.exists()) folder.mkdir(); Desktop.getDesktop().open(folder); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); menu.add(openItem); JMenuItem importItem = new JMenuItem("Import"); importItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { File home = new File(System.getProperty("user.home")); Desktop.getDesktop().open(home); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); menu.add(importItem); JMenuItem newItem = new JMenuItem("New text"); newItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { JTextEditor textEditor = new JTextEditor(); String teLocator$ = textEditor.getLocator(); teLocator$ = Locator.append(teLocator$, Entigrator.ENTIHOME, entihome$); String text$ = "New" + Identity.key().substring(0, 4) + ".txt"; teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT, text$); JFolderPanel fp = new JFolderPanel(); String fpLocator$ = fp.getLocator(); fpLocator$ = Locator.append(fpLocator$, Entigrator.ENTIHOME, entihome$); fpLocator$ = Locator.append(fpLocator$, EntityHandler.ENTITY_KEY, entityKey$); fpLocator$ = Locator.append(fpLocator$, BaseHandler.HANDLER_METHOD, "response"); fpLocator$ = Locator.append(fpLocator$, JRequester.REQUESTER_ACTION, ACTION_CREATE_FILE); String requesterResponseLocator$ = Locator.compressText(fpLocator$); teLocator$ = Locator.append(teLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, requesterResponseLocator$); JConsoleHandler.execute(console, teLocator$); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); menu.add(newItem); //menu.addSeparator(); if (hasToInsert()) { menu.addSeparator(); JMenuItem insertItem = new JMenuItem("Insert"); insertItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable clipboardContents = systemClipboard.getContents(null); if (clipboardContents == null) return; Object transferData = clipboardContents .getTransferData(DataFlavor.javaFileListFlavor); List<File> files = (List<File>) transferData; for (int i = 0; i < files.size(); i++) { File file = (File) files.get(i); if (file.exists() && file.isFile()) { System.out.println("FolderPanel:insert:in=" + file.getPath()); File dir = new File(entihome$ + "/" + entityKey$); if (!dir.exists()) dir.mkdir(); File out = new File(entihome$ + "/" + entityKey$ + "/" + file.getName()); if (!out.exists()) out.createNewFile(); System.out.println("FolderPanel:insert:out=" + out.getPath()); FileExpert.copyFile(file, out); JConsoleHandler.execute(console, getLocator()); } // System.out.println("FolderPanel:import:file="+file.getPath()); } } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); menu.add(insertItem); } if (hasToPaste()) { menu.addSeparator(); JMenuItem pasteItem = new JMenuItem("Paste"); pasteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String[] sa = console.clipboard.getContent(); Properties locator; String file$; File file; File target; String dir$ = entihome$ + "/" + entityKey$; File dir = new File(dir$); if (!dir.exists()) dir.mkdir(); for (String aSa : sa) { try { locator = Locator.toProperties(aSa); if (LOCATOR_TYPE_FILE.equals(locator.getProperty(Locator.LOCATOR_TYPE))) { file$ = locator.getProperty(FILE_PATH); file = new File(file$); target = new File(dir$ + "/" + file.getName()); if (!target.exists()) target.createNewFile(); FileExpert.copyFile(file, target); } } catch (Exception ee) { LOGGER.info(ee.toString()); } } JConsoleHandler.execute(console, locator$); } }); menu.add(pasteItem); } if (hasSelectedItems()) { menu.addSeparator(); JMenuItem 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) { String[] sa = JFolderPanel.this.listSelectedItems(); if (sa == null) return; Properties locator; String file$; File file; for (String aSa : sa) { locator = Locator.toProperties(aSa); file$ = locator.getProperty(FILE_PATH); file = new File(file$); try { if (file.isDirectory()) FileExpert.clear(file$); file.delete(); } catch (Exception ee) { LOGGER.info(ee.toString()); } } } JConsoleHandler.execute(console, locator$); } }); menu.add(deleteItem); JMenuItem copyItem = new JMenuItem("Copy"); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String[] sa = JFolderPanel.this.listSelectedItems(); console.clipboard.clear(); if (sa != null) for (String aSa : sa) console.clipboard.putString(aSa); } }); menu.add(copyItem); JMenuItem exportItem = new JMenuItem("Export"); exportItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { String[] sa = JFolderPanel.this.listSelectedItems(); Properties locator; String file$; File file; ArrayList<File> fileList = new ArrayList<File>(); for (String aSa : sa) { try { locator = Locator.toProperties(aSa); file$ = locator.getProperty(FILE_PATH); file = new File(file$); fileList.add(file); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } File[] fa = fileList.toArray(new File[0]); if (fa.length < 1) return; // System.out.println("Folderpanel:finish:list="+fa.length); JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(System.getProperty("user.home"))); chooser.setDialogTitle("Export files"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showSaveDialog(JFolderPanel.this) == JFileChooser.APPROVE_OPTION) { String dir$ = chooser.getSelectedFile().getPath(); File target; for (File f : fa) { target = new File(dir$ + "/" + f.getName()); if (!target.exists()) target.createNewFile(); FileExpert.copyFile(f, target); } } else { Logger.getLogger(JMainConsole.class.getName()).info(" no selection"); } // System.out.println("Folderpanel:finish:list="+fileList.size()); } catch (Exception eee) { LOGGER.severe(eee.toString()); } } }); menu.add(exportItem); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); return menu; }
From source file:org.ash.gui.MainFrame.java
/** * Menu file exit_action performed.//from w w w .ja v a2 s.com * * @param e the e */ public void menuFileExit_actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(this, Options.getInstance().getResource("quit application?"), Options.getInstance().getResource("attention"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == 0) { if (this.collectorUI != null) this.collectorUI.stop(); if (this.database != null) this.database.close(); System.exit(0); } }
From source file:jboost.visualization.HistogramFrame.java
private File selectPDFFile() { File fFile = new File("default.pdf"); JFileChooser fc = new JFileChooser(); // Start in current directory fc.setCurrentDirectory(new File(".")); // Set filter for Java source files. fc.setFileFilter(new FileFilter() { public boolean accept(File f) { String path = f.getAbsolutePath(); if (f.isDirectory() || path.endsWith(".pdf")) return true; else/* w w w.j a v a 2 s . c om*/ return false; } public String getDescription() { return "PDF Files"; } }); // Set to a default name for save. fc.setSelectedFile(fFile); // Open chooser dialog int result = fc.showSaveDialog(this); if (result == JFileChooser.CANCEL_OPTION) { return null; } else if (result == JFileChooser.APPROVE_OPTION) { fFile = fc.getSelectedFile(); if (fFile.exists()) { int response = JOptionPane.showConfirmDialog(null, "Overwrite existing file?", "Confirm Overwrite", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.CANCEL_OPTION) return null; } return fFile; } else { return null; } }
From source file:com.sshtools.common.ui.SshToolsApplicationClientPanel.java
/** * * * @param disconnect// w w w . j a v a 2 s . c o m */ public void closeConnection(boolean disconnect) { // if (isNeedSave() && (currentConnectionFile != null)) { // Stop save dialog box when not using a pre-existing profile. // Only allow saving of files if allowed by the security manager try { if (System.getSecurityManager() != null) { AccessController.checkPermission(new FilePermission("<<ALL FILES>>", "write")); if (JOptionPane.showConfirmDialog(this, "You have unsaved changes to the connection " + ((currentConnectionFile == null) ? "<Untitled>" : currentConnectionFile.getName()) + ".\nDo you want to save the changes now?", "Unsaved changes", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { saveConnection(false, getCurrentConnectionFile(), getCurrentConnectionProfile()); setNeedSave(false); } } } catch (AccessControlException ace) { log.warn("Changes made to connection, but security manager won't allow saving of files."); } } //setCurrentConnectionFile(null); }
From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_demand.java
public static void createLinkDemandGUI(final NetworkElementType networkElementType, final IVisualizationCallback callback) { final NetPlan netPlan = callback.getDesign(); final JComboBox originNodeSelector = new WiderJComboBox(); final JComboBox destinationNodeSelector = new WiderJComboBox(); for (Node node : netPlan.getNodes()) { final String nodeName = node.getName(); String nodeLabel = "Node " + node.getIndex(); if (!nodeName.isEmpty()) nodeLabel += " (" + nodeName + ")"; originNodeSelector.addItem(StringLabeller.of(node.getId(), nodeLabel)); destinationNodeSelector.addItem(StringLabeller.of(node.getId(), nodeLabel)); }//from w ww . jav a2 s . c om ItemListener nodeListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { long originNodeId = (long) ((StringLabeller) originNodeSelector.getSelectedItem()).getObject(); long destinationNodeId = (long) ((StringLabeller) destinationNodeSelector.getSelectedItem()) .getObject(); callback.putTransientColorInElementTopologyCanvas( Arrays.asList(netPlan.getNodeFromId(originNodeId)), Color.GREEN); callback.putTransientColorInElementTopologyCanvas( Arrays.asList(netPlan.getNodeFromId(destinationNodeId)), Color.CYAN); } }; originNodeSelector.addItemListener(nodeListener); destinationNodeSelector.addItemListener(nodeListener); originNodeSelector.setSelectedIndex(0); destinationNodeSelector.setSelectedIndex(1); JPanel pane = new JPanel(); pane.add(networkElementType == NetworkElementType.LINK ? new JLabel("Origin node: ") : new JLabel("Ingress node: ")); pane.add(originNodeSelector); pane.add(Box.createHorizontalStrut(15)); pane.add(networkElementType == NetworkElementType.LINK ? new JLabel("Destination node: ") : new JLabel("Egress node: ")); pane.add(destinationNodeSelector); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please enter end nodes for the new " + networkElementType, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { long originNodeId = (long) ((StringLabeller) originNodeSelector.getSelectedItem()).getObject(); long destinationNodeId = (long) ((StringLabeller) destinationNodeSelector.getSelectedItem()) .getObject(); Node originNode = netPlan.getNodeFromId(originNodeId); Node destinationNode = netPlan.getNodeFromId(destinationNodeId); if (netPlan.getNodeFromId(originNodeId) == null) throw new Net2PlanException("Node of id: " + originNodeId + " does not exist"); if (netPlan.getNodeFromId(destinationNodeId) == null) throw new Net2PlanException("Node of id: " + destinationNodeId + " does not exist"); if (networkElementType == NetworkElementType.LINK) { final Link e = netPlan.addLink(originNode, destinationNode, 0, 0, 200000, null); callback.getVisualizationState() .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.LINK)); callback.getVisualizationState().pickLink(e); callback.updateVisualizationAfterPick(); callback.getUndoRedoNavigationManager().addNetPlanChange(); } else { final Demand d = netPlan.addDemand(originNode, destinationNode, 0, null); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.DEMAND)); callback.getVisualizationState().pickDemand(d); callback.updateVisualizationAfterPick(); callback.getUndoRedoNavigationManager().addNetPlanChange(); } break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error adding " + networkElementType); } } }
From source file:jboost.visualization.HistogramFrame.java
private File selectDumpFile() { File fFile = new File("ExamplesDumpFile.txt"); JFileChooser fc = new JFileChooser(); // Start in current directory fc.setCurrentDirectory(new File(".")); // Set filter for Java source files. fc.setFileFilter(new FileFilter() { public boolean accept(File f) { String path = f.getAbsolutePath(); if (f.isDirectory() || path.endsWith(".txt")) return true; else//from w w w. ja v a2s . c om return false; } public String getDescription() { return "Text Files"; } }); // Set to a default name for save. fc.setSelectedFile(fFile); // Open chooser dialog int result = fc.showSaveDialog(this); if (result == JFileChooser.CANCEL_OPTION) { return null; } else if (result == JFileChooser.APPROVE_OPTION) { fFile = fc.getSelectedFile(); if (fFile.exists()) { int response = JOptionPane.showConfirmDialog(null, "Overwrite existing file?", "Confirm Overwrite", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.CANCEL_OPTION) return null; } return fFile; } else { return null; } }
From source file:UserInterface.FinanceRole.TransferToRegSiteJPanel.java
private void autoTransferJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_autoTransferJButtonActionPerformed //Validation/* w w w . ja va 2 s .com*/ boolean validationSuccess; validationSuccess = validationAutoTansfer(); if (validationSuccess) { objWorldEnterprise.getObjTransactionDirectory().updateTransactionAccount(); BigDecimal worldDonation = AutoTransfer.transferCheck(objWorldEnterprise, objUserAccount, autoDonationAmount); BigDecimal worldBalance = objWorldEnterprise.getObjTransactionDirectory().getAvailableRealBalance(); System.out.println(worldDonation); System.out.println(objWorldEnterprise.getObjTransactionDirectory().getAvailableRealBalance()); System.out.println(objWorldEnterprise.getObjTransactionDirectory().getAvailableVirtualBalance()); int positiveWorldBalance = worldBalance.compareTo(worldDonation); if (positiveWorldBalance >= 1) { JDialog.setDefaultLookAndFeelDecorated(true); int response = JOptionPane.showConfirmDialog(null, "Total transfer of $ " + worldDonation + "/- Do you want to transfer?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { System.out.println("Yes button clicked"); worldDonation = AutoTransfer.transferConfirm(objWorldEnterprise, objUserAccount, autoDonationAmount); JOptionPane.showMessageDialog(null, "$ " + worldDonation + "/- transferred successfully"); autoTransferJTextField.setText(null); populateLowRegSiteTable(); } } else { JOptionPane.showMessageDialog(null, "World Balance is low"); } } }