Java Code Examples for javax.swing.JOptionPane
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
public void handle(Throwable e){ e.printStackTrace(); JTextArea area=new JTextArea(10,40); StringWriter writer=new StringWriter(); e.printStackTrace(new PrintWriter(writer)); area.setText(writer.toString()); area.setCaretPosition(0); String copyOption=resources.getString("dialog.error.copy"); JOptionPane pane=new JOptionPane(new JScrollPane(area),JOptionPane.ERROR_MESSAGE,JOptionPane.YES_NO_OPTION,null,new String[]{copyOption,resources.getString("cancel")}); pane.createDialog(WorldFrame.this,e.toString()).setVisible(true); if (copyOption.equals(pane.getValue())) { area.setSelectionStart(0); area.setSelectionEnd(area.getText().length()); area.copy(); } }
Example 2
From project Clotho-Core, under directory /ClothoProject/ClothoCore/src/org/clothocore/api/data/.
Source file: Person.java

/** * Plugin-accessible method for changing the Person's password * @param raw */ public final void changePassword(String raw){ String newpass=SHA1(raw); if (_personDatum._password == null || _personDatum._password.equals("")) { } else { if (!checkPassword()) { JOptionPane.showMessageDialog(null,"I'm sorry, your password didn't match. I'm canceling the change.","Error",JOptionPane.ERROR_MESSAGE); fireData(new RefreshEvent(this,RefreshEvent.Condition.SECURITY_CHANGED)); return; } } final JPasswordField jpf=new JPasswordField(); JOptionPane jop=new JOptionPane(jpf,JOptionPane.QUESTION_MESSAGE,JOptionPane.OK_OPTION); JDialog dialog=jop.createDialog("Please retype your password:"); dialog.setVisible(true); jpf.requestFocusInWindow(); int result=(Integer)jop.getValue(); dialog.dispose(); char[] chars=jpf.getPassword(); String rawValue=""; for ( char c : chars) { rawValue+=c; } String inputValue=SHA1(rawValue); if (newpass.equals(inputValue)) { addUndo("_password",_personDatum._password,inputValue); _personDatum._password=inputValue; JOptionPane.showMessageDialog(null,"Your password has been changed.","Confirmed",JOptionPane.OK_OPTION); setChanged(org.clothocore.api.dnd.RefreshEvent.Condition.SECURITY_CHANGED); } else { JOptionPane.showMessageDialog(null,"I'm sorry, your password didn't match. I'm canceling the change.","Error",JOptionPane.ERROR_MESSAGE); fireData(new RefreshEvent(this,RefreshEvent.Condition.SECURITY_CHANGED)); } }
Example 3
From project codjo-standalone-common, under directory /src/main/java/net/codjo/gui/imports/.
Source file: ImportSettingsDetailWindow.java

/** * DOCUMENT ME! * @param evt Description of Parameter */ void FIELD_SEPARATOR_actionPerformed(ActionEvent evt){ if ("Autre".equals(FIELD_SEPARATOR.getSelectedItem())) { JOptionPane newFieldSeparator=new JOptionPane(); String inputValue=newFieldSeparator.showInputDialog(this,"Tapez le nouveau s?arateur (Un caract?e):","S?arateur",newFieldSeparator.DEFAULT_OPTION); if (inputValue != null) { if (inputValue.length() == 1) { FIELD_SEPARATOR.addItem(inputValue); FIELD_SEPARATOR.setSelectedItem(inputValue); } else { FIELD_SEPARATOR.setSelectedIndex(-1); newFieldSeparator.showMessageDialog(this,"Veuillez saisir un caract?e.","Alert",newFieldSeparator.ERROR_MESSAGE); } } else { FIELD_SEPARATOR.setSelectedIndex(-1); } } }
Example 4
From project codjo-data-process, under directory /codjo-data-process-gui/src/main/java/net/codjo/dataprocess/gui/util/.
Source file: GenericInputDialog.java

/** * Creates the reusable dialog. */ public GenericInputDialog(Frame aFrame,String title,String labelInput,DialogInputControl dialogInputControl){ super(aFrame,true); this.dialogInputControl=dialogInputControl; setTitle(title); textField=new JTextField(30); Object[] array={labelInput,textField}; Object[] options={btnString1,"Annuler"}; optionPane=new JOptionPane(array,JOptionPane.QUESTION_MESSAGE,JOptionPane.YES_NO_OPTION,null,options,options[0]); setContentPane(optionPane); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter(){ @Override public void windowClosing( WindowEvent we){ optionPane.setValue(JOptionPane.CLOSED_OPTION); } } ); textField.addActionListener(this); optionPane.addPropertyChangeListener(this); pack(); }
Example 5
From project addis, under directory /application/src/main/java/org/drugis/addis/gui/.
Source file: AddDrugDialog.java

@Override protected void commit(){ if (d_domain.getDrugs().contains(d_drug)) { JOptionPane.showMessageDialog(d_mainWindow,"An item with the name " + d_drug.getName() + " already exists in the domain.","Couldn't add Drug",JOptionPane.ERROR_MESSAGE); return; } d_domain.getDrugs().add(d_drug); dispose(); d_mainWindow.leftTreeFocus(d_drug); if (d_selectionModel != null) d_selectionModel.setValue(d_drug); }
Example 6
public BladeDialog(Node node){ super(node.gameFrame); this.setLocationRelativeTo(node.gameFrame); this.setUndecorated(true); this.setVisible(true); String confirmStr=node.getGameInfo().powerVS(node.getGameInfo().getLastSelect()) + "\n\nWould you like to use the blade?"; int options=JOptionPane.showConfirmDialog(this,confirmStr,"Operation Prompt",JOptionPane.YES_NO_OPTION); if (options == JOptionPane.YES_OPTION) { node.getMyFamilyInfo().setBladeRemain(0); try { node.sendGameStatusUpdate(MessageType.Blade); } catch ( Exception e) { e.printStackTrace(); } this.dispose(); } if (options == JOptionPane.NO_OPTION) { try { node.sendGameStatusUpdate(MessageType.Blade); } catch ( Exception e) { e.printStackTrace(); } this.dispose(); } }
Example 7
From project androvoip, under directory /src/com/mexuar/corraleta/faceless/.
Source file: Faceless.java

public void showTrialDaysLeft(){ int daysLeft=trialDaysLeft(); if (isTrial() == true) { JOptionPane.showMessageDialog(null,"Mexuar Communications - Corraleta SDK 30 day trial version.\n" + "This software will expire in " + daysLeft + " day(s).","Mexuar Communications - Corraleta SDK",JOptionPane.WARNING_MESSAGE); } }
Example 8
From project ANNIS, under directory /annis-kickstarter/src/main/java/de/hu_berlin/german/korpling/annis/kickstarter/.
Source file: ImportDialog.java

@Override protected void done(){ isImporting=false; btOk.setEnabled(true); btSearchInputDir.setEnabled(true); txtInputDir.setEnabled(true); lblCurrentCorpus.setText(""); pbCorpus.setValue(pbCorpus.getMaximum()); pbImport.setIndeterminate(false); try { if (!isCancelled()) { Status status=this.get(); if (status.ok) { JOptionPane.showMessageDialog(null,"Corpus imported.","INFO",JOptionPane.INFORMATION_MESSAGE); setVisible(false); } else { new ExceptionDialog(status.ex,"Import failed").setVisible(true); setVisible(false); } } } catch ( Exception ex) { log.error(null,ex); } }
Example 9
From project autopsy, under directory /Core/src/org/sleuthkit/autopsy/casemodule/.
Source file: AddImageAction.java

/** * Pop-up the "Add Image" wizard panel. * @param e */ @Override public void actionPerformed(ActionEvent e){ Logger.noteAction(AddImageAction.class); final IngestConfigurator ingestConfig=Lookup.getDefault().lookup(IngestConfigurator.class); if (ingestConfig.isIngestRunning()) { final String msg="<html>Ingest is ongoing on another image. Adding a new image now might slow down the current ingest.<br />Do you want to proceed and add a new image now?</html>"; if (JOptionPane.showConfirmDialog(null,msg,"Ingest in progress",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) { return; } } iterator=new AddImageWizardIterator(this); wizardDescriptor=new WizardDescriptor(iterator); wizardDescriptor.setTitle("Add Image"); wizardDescriptor.putProperty(NAME,e); if (dialog != null) { dialog.setVisible(false); } dialog=DialogDisplayer.getDefault().createDialog(wizardDescriptor); dialog.setVisible(true); dialog.toFront(); runCleanupTasks(); }
Example 10
From project beam-third-party, under directory /beam-wew-water/src/main/java/wew/water/.
Source file: WaterProcessorUI.java

private void checkForValidInputProduct(Parameter parameter){ Object value=parameter.getValue(); File file=null; if (value instanceof File) { file=(File)value; } if (value instanceof String) { file=new File((String)value); } if (file == null || !file.exists()) { return; } String msg=null; try { Product product=ProductIO.readProduct(file); if (product != null) { } else { msg="Unknown file format."; } } catch ( IOException e) { msg=e.getMessage(); } if (msg != null) { JOptionPane.showMessageDialog(getGuiComponent(),"Invalid input file:\n" + msg,WaterProcessor.PROCESSOR_NAME,JOptionPane.ERROR_MESSAGE); } }
Example 11
public boolean queryExit(){ if (isCurrentDocModified()) { int saveChanges=docIOMngr.showModifiedWarning(this,getCurrentDocTitle()); if (saveChanges == JOptionPane.YES_OPTION) { try { return docIOMngr.save(this,new BMAFileFilter()); } catch ( IOException ioe) { showError("BMach - Error","I/O error:","An error occured while trying to save the file"); return false; } } else if (saveChanges == JOptionPane.NO_OPTION) { return true; } else { return false; } } else { return true; } }
Example 12
From project bndtools, under directory /bndtools.bndplugins/src/bndtools/bndplugins/repo/git/.
Source file: GitCredentialsProvider.java

@Override public boolean get(URIish uri,CredentialItem... items) throws UnsupportedCredentialItem { Mapping mapping=repo.findMapping(uri.toString()); if (mapping != null) { for ( CredentialItem item : items) { if (item instanceof CredentialItem.Username) { ((CredentialItem.Username)item).setValue(mapping.user); continue; } if (item instanceof CredentialItem.Password) { ((CredentialItem.Password)item).setValue(mapping.pass); continue; } if (item instanceof CredentialItem.StringType && item.isValueSecure()) { ((CredentialItem.StringType)item).setValue(new String(mapping.pass)); continue; } } return true; } if (isInteractive()) { JComponent[] inputs=getSwingUI(items); int result=JOptionPane.showConfirmDialog(null,inputs,"Enter credentials for " + repo.getName(),JOptionPane.OK_CANCEL_OPTION,JOptionPane.PLAIN_MESSAGE); if (result != JOptionPane.OK_OPTION) { return false; } updateCredentialItems(inputs); return true; } return false; }
Example 13
private void tryToLoadFileFromArgument(String[] args){ if (args.length == 0) return; File fileArg=new File(args[0]); if (fileArg.exists() && fileArg.getAbsolutePath().trim().endsWith(".pdf")) { try { importNewPdfFile(fileArg); } catch ( IOException e) { JOptionPane.showMessageDialog(this,e.getMessage(),"Briss error",JOptionPane.ERROR_MESSAGE); } catch ( PdfException e) { JOptionPane.showMessageDialog(this,e.getMessage(),"Briss error",JOptionPane.ERROR_MESSAGE); } } }
Example 14
public boolean promptPassword(String message){ Object[] ob={passwordField}; int result=JOptionPane.showConfirmDialog(null,ob,message,JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { passwd=passwordField.getText(); return true; } else { return false; } }
Example 15
From project ceres, under directory /ceres-ui/src/main/java/com/bc/ceres/swing/demo/.
Source file: FigureEditorApp.java

@Override public void actionPerformed(ActionEvent event){ File lastDir=new File(Preferences.userNodeForPackage(FigureEditorApp.class).get("lastDir",".")); JFileChooser chooser=new JFileChooser(lastDir); chooser.setAcceptAllFileFilterUsed(true); int i=chooser.showOpenDialog(frame); if (i == JFileChooser.APPROVE_OPTION && chooser.getSelectedFile() != null) { Preferences.userNodeForPackage(FigureEditorApp.class).put("lastDir",chooser.getCurrentDirectory().getPath()); figureEditorPanel.getFigureEditor().getFigureSelection().removeAllFigures(); figureEditorPanel.getFigureEditor().getFigureCollection().removeAllFigures(); try { loadFigureCollection(chooser.getSelectedFile(),figureEditorPanel.getFigureEditor().getFigureCollection()); } catch ( IOException e) { JOptionPane.showMessageDialog(getFrame(),"Error: " + e.getMessage()); } } }
Example 16
From project codjo-segmentation, under directory /codjo-segmentation-gui/src/main/java/net/codjo/segmentation/gui/editor/.
Source file: EditorWindow.java

private boolean isFormulaIsUsedByIncludes(){ try { ResultManager resultManager=findIncludes(); Collection results=resultManager.getResults(); if (results == null) { return true; } for ( Object result : results) { List<Row> list=((Result)result).getRows(); if (list == null) { return true; } StringBuffer includesInfo=new StringBuffer(); for ( Row row : list) { String classificationName=row.getFieldValue("classificationName"); String sleeveName=row.getFieldValue("sleeveName"); if (isCycleExists(row,sleeveName,classificationName)) { return false; } includesInfo.append("'").append(sleeveName).append("' de l'axe '").append(classificationName).append("'\n"); } int answer=JOptionPane.showConfirmDialog(this,"Cette poche est utilis? dans les poches :\n" + includesInfo + "Etes-vous certain de vouloir la modifier ?","Confirmation",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE); if (answer == JOptionPane.NO_OPTION) { return false; } } } catch ( RequestException e) { LOG.error("Erreur lors du contr?e des alias",e); } return true; }
Example 17
protected void onOK(){ try { this.m_port=Integer.parseInt(m_field_port.getText()); this.m_password=m_field_password.getText(); if (this.m_port > 65535) { NumberFormatException ex=new NumberFormatException("Port too large: " + this.m_port); throw ex; } this.m_nickname=m_field_nickname.getText(); if (m_nickname.length() < 1) { BadUsernameException ex=new BadUsernameException("empty username"); throw ex; } this.m_bool=true; dispose(); } catch ( NumberFormatException e) { JOptionPane.showMessageDialog(null,"Port out of Range(1-65535)"); } catch ( BadUsernameException e) { JOptionPane.showMessageDialog(null,"Empty Username"); } }
Example 18
From project Cooking-to-Goal, under directory /src/com/customfit/ctg/controller/.
Source file: RecipeManagement.java

/** * Activates Create Recipe application feature, which in this case sends the Recipe object over to the Controller's default data driver. This method is also used as a callback from the Create Recipe JPanel upon saving the newly created Recipe. * @param recipe The completed Recipe object ready to store. * @return Boolean indicating the success of the operation. */ public static boolean createRecipeAndGoBack(Recipe recipe){ boolean status=Application.getDataDriver().insertRecipe(recipe); if (!status) JOptionPane.showMessageDialog(Application.getMainFrame(),"There was a problem creating your recipe.","Error",JOptionPane.ERROR_MESSAGE); else { Application.getMainFrame().goBack(); } return status; }