List of usage examples for javax.swing JOptionPane showConfirmDialog
public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType, int messageType) throws HeadlessException
optionType
parameter, where the messageType
parameter determines the icon to display. From source file:edu.clemson.cs.nestbed.client.gui.TestbedManagerFrame.java
private void doExit() { int choice;//ww w. j a v a2 s. c om choice = JOptionPane.showConfirmDialog(this, "Do you wish to exit NESTbed?", "Exit Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (choice == JOptionPane.YES_OPTION) { log.fatal("Application shutdown per user request."); System.exit(0); } }
From source file:com.sshtools.tunnel.PortForwardingPane.java
protected void addPortForward() { PortForwardEditorPane editor = new PortForwardEditorPane(); int option = JOptionPane.showConfirmDialog(this, editor, "Add New Tunnel", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (option != JOptionPane.CANCEL_OPTION && option != JOptionPane.CLOSED_OPTION) { try {/*from w w w . j av a2s .c om*/ ForwardingClient forwardingClient = client; //.getForwardingClient(); String id = editor.getForwardName(); if (id.equals("x11")) { throw new Exception("The id of x11 is reserved."); } int i = model.getRowCount(); if (editor.isLocal()) { ForwardingConfiguration f = forwardingClient.addLocalForwarding(id, editor.getBindAddress(), editor.getLocalPort(), editor.getHost(), editor.getRemotePort()); forwardingClient.startLocalForwarding(id); active.addConfiguration(f); } else { ForwardingConfiguration f = forwardingClient.addRemoteForwarding(id, editor.getBindAddress(), editor.getLocalPort(), editor.getHost(), editor.getRemotePort()); forwardingClient.startRemoteForwarding(id); active.addConfiguration(f); } if (i < model.getRowCount()) { table.getSelectionModel().addSelectionInterval(i, i); } } catch (Exception e) { sessionPanel.setAvailableActions(); JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } finally { model.refresh(); sessionPanel.setAvailableActions(); } } }
From source file:gdt.jgui.entity.fields.JFieldsEditor.java
/** * Get the context menu.//from w w w .j a v a 2 s. c om * @return the context menu. */ @Override public JMenu getContextMenu() { menu = new JMenu("Context"); menu.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { // System.out.println("FieldsEditor:getConextMenu:menu selected"); if (editCellItem != null) menu.remove(editCellItem); if (deleteItemsItem != null) menu.remove(deleteItemsItem); if (copyItem != null) menu.remove(copyItem); if (pasteItem != null) menu.remove(pasteItem); if (cutItem != null) menu.remove(cutItem); if (hasEditingCell()) { editCellItem = new JMenuItem("Edit item"); editCellItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { JTextEditor textEditor = new JTextEditor(); String locator$ = textEditor.getLocator(); locator$ = Locator.append(locator$, Entigrator.ENTIHOME, entihome$); locator$ = Locator.append(locator$, EntityHandler.ENTITY_KEY, entityKey$); String responseLocator$ = getEditCellLocator(); text$ = Locator.getProperty(responseLocator$, JTextEditor.TEXT); locator$ = Locator.append(locator$, JTextEditor.TEXT, text$); // System.out.println("FieldsEditor:edit cell:text="+text$); locator$ = Locator.append(locator$, JRequester.REQUESTER_RESPONSE_LOCATOR, Locator.compressText(responseLocator$)); JConsoleHandler.execute(console, locator$); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); menu.add(editCellItem); } if (hasSelectedRows()) { deleteItemsItem = new JMenuItem("Delete items"); deleteItemsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(JFieldsEditor.this, "Delete selected fields ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { deleteRows(); } } }); menu.add(deleteItemsItem); copyItem = new JMenuItem("Copy"); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { copy(false); } }); menu.add(copyItem); cutItem = new JMenuItem("Cut"); cutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { copy(true); } }); menu.add(cutItem); } if (hasFieldsToPaste()) { pasteItem = new JMenuItem("Paste"); pasteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { String[] sa = console.clipboard.getContent(); Properties locator; String type$; String sourceEntityKey$; Sack sourceEntity; String sourceEntihome$; Entigrator sourceEntigrator; for (String aSa : sa) { //System.out.println("FieldsEditor:paste:"+aSa); locator = Locator.toProperties(aSa); type$ = locator.getProperty(Locator.LOCATOR_TYPE); if (LOCATOR_TYPE_FIELD.equals(type$)) { String action$ = locator.getProperty(JRequester.REQUESTER_ACTION); String name$ = locator.getProperty(CELL_FIELD_NAME); String value$ = locator.getProperty(CELL_FIELD_VALUE); if (name$ != null) { if (ACTION_COPY_FIELDS.equals(action$)) entity.putElementItem("field", new Core(null, name$, value$)); if (ACTION_CUT_FIELDS.equals(action$)) { entity.putElementItem("field", new Core(null, name$, value$)); sourceEntihome$ = locator.getProperty(Entigrator.ENTIHOME); sourceEntigrator = console.getEntigrator(sourceEntihome$); sourceEntityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); sourceEntity = sourceEntigrator.getEntityAtKey(sourceEntityKey$); sourceEntity.removeElementItem("field", name$); sourceEntigrator.save(sourceEntity); } } } } entigrator.save(entity); Core[] ca = entity.elementGet("field"); replaceTable(ca); } catch (Exception ee) { LOGGER.info(ee.toString()); } } }); menu.add(pasteItem); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); doneItem = new JMenuItem("Done"); doneItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); if (requesterResponseLocator$ != null) { try { byte[] ba = Base64.decodeBase64(requesterResponseLocator$); String responseLocator$ = new String(ba, "UTF-8"); responseLocator$ = Locator.append(responseLocator$, Entigrator.ENTIHOME, entihome$); responseLocator$ = Locator.append(responseLocator$, EntityHandler.ENTITY_KEY, entityKey$); // System.out.println("FieldsEditor:done.response locator="+responseLocator$); JConsoleHandler.execute(console, responseLocator$); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } else console.back(); } }); menu.add(doneItem); JMenuItem cancelItem = new JMenuItem("Cancel"); cancelItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { console.back(); } }); menu.add(cancelItem); menu.addSeparator(); JMenuItem addItemItem = new JMenuItem("Add item"); addItemItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addRow(); } }); menu.add(addItemItem); if (postMenu != null) { //System.out.println("JFieldsEditor:postMenu="+postMenu.length); for (JMenuItem jmi : postMenu) menu.add(jmi); } //else // System.out.println("JFieldsEditor:postMenu empty"); return menu; }
From source file:com.bsoft.baseframe.baseframe_utils.beanUtils.Classgenerator.java
/** * ?// ww w.j a v a 2 s.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:com.enderville.enderinstaller.ui.Installer.java
private void advanceStep() { step++;//from w ww. j a v a 2 s . c om 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:org.jfree.demo.DrawStringDemo.java
/** * Displays a primitive font chooser dialog to allow the user to change the font. *//* ww w . j av a 2 s. c o m*/ private void displayFontDialog() { final FontChooserPanel panel = new FontChooserPanel(this.drawStringPanel1.getFont()); final int result = JOptionPane.showConfirmDialog(this, panel, "Font Selection", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { this.drawStringPanel1.setFont(panel.getSelectedFont()); this.drawStringPanel2.setFont(panel.getSelectedFont()); } }
From source file:com.dmrr.asistenciasx.Horarios.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed try {/*from w ww . j a v a 2 s . c o m*/ int x = jTableHorarios.getSelectedRow(); if (x == -1) { JOptionPane.showMessageDialog(this, "Seleccione un profesor primero", "Datos incompletos", JOptionPane.WARNING_MESSAGE); return; } Integer idProfesor = Integer .parseInt((String) jTableHorarios.getValueAt(jTableHorarios.getSelectedRow(), 1)); JPasswordField pf = new JPasswordField(); String nip = ""; int okCxl = JOptionPane.showConfirmDialog(null, pf, "Introduzca el NIP del jefe del departamento", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (okCxl == JOptionPane.OK_OPTION) { nip = new String(pf.getPassword()); } else { return; } org.jsoup.Connection.Response respuesta = Jsoup .connect("http://siiauescolar.siiau.udg.mx/wus/gupprincipal.valida_inicio") .data("p_codigo_c", "2225255", "p_clave_c", nip).method(org.jsoup.Connection.Method.POST) .timeout(0).execute(); Document login = respuesta.parse(); String sessionId = respuesta.cookie(getFecha() + "SIIAUSESION"); String sessionId2 = respuesta.cookie(getFecha() + "SIIAUUDG"); Document listaHorarios = Jsoup.connect("http://siiauescolar.siiau.udg.mx/wse/sspsecc.consulta_oferta") .data("ciclop", "201510", "cup", "J", "deptop", "", "codprofp", "" + idProfesor, "ordenp", "0", "mostrarp", "1000", "tipop", "T", "secp", "A", "regp", "T") .userAgent("Mozilla").cookie(getFecha() + "SIIAUSESION", sessionId) .cookie(getFecha() + "SIIAUUDG", sessionId2).timeout(0).post(); Elements tabla = listaHorarios.select("body"); tabla.select("style").remove(); Elements font = tabla.select("font"); font.removeAttr("size"); System.out.println(tabla.html()); JEditorPane jEditorPane = new JEditorPane(); jEditorPane.setEditable(false); HTMLEditorKit kit = new HTMLEditorKit(); jEditorPane.setEditorKit(kit); javax.swing.text.Document doc = kit.createDefaultDocument(); jEditorPane.setDocument(doc); jEditorPane.setText(tabla.html()); JOptionPane.showMessageDialog(null, jEditorPane); } catch (IOException ex) { Logger.getLogger(Horarios.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:burlov.ultracipher.swing.MainPanel.java
private void deleteCurrentEntry() { DataEntry entry = editDataPanel.getData(); if (entry != null) { // int ret = JOptionPane.showOptionDialog(getMainFrame(), // "Delete entry?", "Confirm", // JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, // null, JOptionPane.NO_OPTION); int ret = JOptionPane.showConfirmDialog(SwingGuiApplication.getInstance().getMainFrame(), "Delete entry?", "Warning", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); if (ret == JOptionPane.OK_OPTION) { SwingGuiApplication.getInstance().getDatabase().deleteEntry(entry); SwingGuiApplication.getInstance().updateNeedSave(true); searchResultModel.removeElement(entry); editDataPanel.editData(null, false); searchResults.clearSelection(); }//from ww w.j av a 2s . c o m } }
From source file:de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.MainM.java
private static int askForEnablingKEGG() { JOptionPane.showMessageDialog(null, "<html><h3>KEGG License Status Evaluation</h3>" + "While VANTED is available as a academic research tool at no cost to commercial and non-commercial users, for using<br>" + "KEGG related functions, it is necessary for all users to adhere to the KEGG license.<br>" + "For using VANTED you need also be aware of information about licenses and conditions for<br>" + "usage, listed at the program info dialog and the VANTED website (http://vanted.ipk-gatersleben.de).<br><br>" + "VANTED does not distribute information from KEGG but contains functionality for the online-access to <br>" + "information from KEGG website.<br><br>" + "<b>Before these functions are available to you, you should carefully read the following license information<br>" + "and decide if it is legit for you to use the KEGG related program functions. If you choose not to use the KEGG functions<br>" + "all other features of this application are still available and fully working.", "VANTED Program Features Initialization", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, "<html><h3>KEGG License Status Evaluation</h3>" + MenuItemInfoDialog.getKEGGlibText(), "VANTED Program Features Initialization", JOptionPane.INFORMATION_MESSAGE); int result = JOptionPane.showConfirmDialog(null, "<html><h3>Enable KEGG functions?", "VANTED Program Features Initialization", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); return result; }
From source file:gate.corpora.CSVImporter.java
@Override protected List<Action> buildActions(final NameBearerHandle handle) { List<Action> actions = new ArrayList<Action>(); if (!(handle.getTarget() instanceof Corpus)) return actions; actions.add(new AbstractAction("Populate from CSV File") { @Override//w ww .ja v a 2 s . co m public void actionPerformed(ActionEvent e) { // display the populater dialog and return if it is cancelled if (JOptionPane.showConfirmDialog(null, dialog, "Populate From CSV File", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) != JOptionPane.OK_OPTION) return; // we want to run the population in a separate thread so we don't lock // up the GUI Thread thread = new Thread(Thread.currentThread().getThreadGroup(), "CSV Corpus Populater") { public void run() { try { // unescape the strings that define the format of the file and // get the actual chars char separator = StringEscapeUtils.unescapeJava(txtSeparator.getText()).charAt(0); char quote = StringEscapeUtils.unescapeJava(txtQuoteChar.getText()).charAt(0); // see if we can convert the URL to a File instance File file = null; try { file = Files.fileFromURL(new URL(txtURL.getText())); } catch (IllegalArgumentException iae) { // this will happen if someone enters an actual URL, but we // handle that later so we can just ignore the exception for // now and keep going } if (file != null && file.isDirectory()) { // if we have a File instance and that points at a directory // then.... // get all the CSV files in the directory structure File[] files = Files.listFilesRecursively(file, CSV_FILE_FILTER); for (File f : files) { // for each file... // skip directories as we don't want to handle those if (f.isDirectory()) continue; if (cboDocuments.isSelected()) { // if we are creating lots of documents from a single // file // then call the populate method passing through all the // options from the GUI populate((Corpus) handle.getTarget(), f.toURI().toURL(), txtEncoding.getText(), (Integer) textColModel.getValue(), cboFeatures.isSelected(), separator, quote); } else { // if we are creating a single document from a single // file // then call the createDoc method passing through all // the // options from the GUI createDoc((Corpus) handle.getTarget(), f.toURI().toURL(), txtEncoding.getText(), (Integer) textColModel.getValue(), cboFeatures.isSelected(), separator, quote); } } } else { // we have a single URL to process so... if (cboDocuments.isSelected()) { // if we are creating lots of documents from a single file // then call the populate method passing through all the // options from the GUI populate((Corpus) handle.getTarget(), new URL(txtURL.getText()), txtEncoding.getText(), (Integer) textColModel.getValue(), cboFeatures.isSelected(), separator, quote); } else { // if we are creating a single document from a single file // then call the createDoc method passing through all the // options from the GUI createDoc((Corpus) handle.getTarget(), new URL(txtURL.getText()), txtEncoding.getText(), (Integer) textColModel.getValue(), cboFeatures.isSelected(), separator, quote); } } } catch (Exception e) { // TODO give a sensible error message e.printStackTrace(); } } }; // let's leave the GUI nice and responsive thread.setPriority(Thread.MIN_PRIORITY); // lets get to it and do some actual work! thread.start(); } }); return actions; }