List of usage examples for javax.swing JOptionPane ERROR_MESSAGE
int ERROR_MESSAGE
To view the source code for javax.swing JOptionPane ERROR_MESSAGE.
Click Source Link
From source file:captureplugin.drivers.DeviceCreatorDialog.java
/** * OK was pressed//from w ww. ja v a 2 s.co m */ private void okPressed() { if (StringUtils.isBlank(mName.getText())) { JOptionPane.showMessageDialog(this, mLocalizer.msg("NoName", "No Name was entered"), Localizer.getLocalization(Localizer.I18N_ERROR), JOptionPane.ERROR_MESSAGE); } else { mRetmode = JOptionPane.OK_OPTION; setVisible(false); } }
From source file:com.stam.batchmove.SelectionFrame.java
private void importFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importFileActionPerformed String path = sourceDir.getText(); if (path == null || path.trim().equals("")) { JOptionPane.showMessageDialog(this, "You must first select a source directory", "Error", JOptionPane.ERROR_MESSAGE); return;//from w w w . ja v a 2 s. c o m } fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setDialogTitle("Choose file to import"); int retVal = fileChooser.showOpenDialog(this); if (retVal == JFileChooser.APPROVE_OPTION) { File sourceDir = new File(path); File[] sourceDirFilesArr = sourceDir.listFiles(); List<File> sourceDirFiles = Arrays.asList(sourceDirFilesArr); File selection = fileChooser.getSelectedFile(); List<File> files = new ArrayList<>(); try (BufferedReader br = new BufferedReader(new FileReader(selection))) { for (String line; (line = br.readLine()) != null;) { if (line != null && !line.trim().equals("")) { File file = BatchMoveUtils.findFileByName(sourceDirFiles, line); if (file != null) { files.add(file); } } } } catch (IOException ex) { ex.printStackTrace(); } String[] columnNames = { "", "Filename", "Size", "Status" }; Object[][] data = new Object[files.size()][4]; int fileNo = 0; for (File file : files) { data[fileNo][0] = file.exists(); data[fileNo][1] = file.getAbsolutePath(); data[fileNo][2] = file.length(); data[fileNo][3] = file.exists() ? "Found" : "Not found"; fileNo++; } BatchMoveUtils.showFilesFrame(data, columnNames, this); } }
From source file:com.alvermont.terraj.planet.ui.MainFrame.java
/** Creates new form MainFrame */ public MainFrame() { initComponents();/*from w w w .j a v a2 s .c om*/ boolean nativeLAF = true; try { prefs = Preferences.userNodeForPackage(MainFrame.class); nativeLAF = prefs.getBoolean(PREF_NAME_NATIVE_LAF, true); } catch (AccessControlException ace) { log.error("No access to preferences? JNLP?", ace); } if (!lafUtils.setSystemLookAndFeel(nativeLAF, this)) { JOptionPane.showMessageDialog(this, "Couldn't set look and feel", "Error", JOptionPane.ERROR_MESSAGE); } nativeLAFCheckbox.setSelected(nativeLAF); this.xmlChooser = new JNLPFileChooser(".xml"); this.textChooser = new JNLPFileChooser(".txt"); this.rgbChooser = new JNLPFileChooser(".rgb"); this.params = new AllPlanetParameters(); setListModel(); latSpinner.setEditor(new JSpinner.NumberEditor(latSpinner, "00.000")); lonSpinner.setEditor(new JSpinner.NumberEditor(lonSpinner, "000.000")); vgridSpinner.setEditor(new JSpinner.NumberEditor(vgridSpinner, "00.000")); hgridSpinner.setEditor(new JSpinner.NumberEditor(hgridSpinner, "000.000")); // TODO: verify range of valid values for scale scaleSpinner.setEditor(new JSpinner.NumberEditor(scaleSpinner, "0.00")); seedField.setValue(0.0); seedField.setInputVerifier(new FormattedTextFieldVerifier()); setComboNumericEditor(widthComboBox); setComboNumericEditor(heightComboBox); updateAllFromParameters(); xmlChooser.addChoosableFileFilter(new XMLFileFilter()); }
From source file:jpad.MainEditor.java
public void openFile() { if (_isOSX || ostype == ostype.Linux || ostype == ostype.Other) { openFile_OSX_Nix();// w w w .j av a 2 s .c o m } else { JFileChooser fc = new JFileChooser(); fc.setDialogTitle("Open a Text File"); fc.setFileFilter(new FileNameExtensionFilter("Plain Text Files", "txt")); int returnval = fc.showOpenDialog(this); if (returnval == 0) { hasSavedToFile = true; hasChanges = false; curFile = fc.getSelectedFile().getAbsolutePath(); try (FileInputStream stream = new FileInputStream(curFile)) { String file = IOUtils.toString(stream); mainTextArea.setText(file); this.setTitle(String.format("JPad - %s", curFile)); } catch (IOException ex) { JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } } }
From source file:mx.jalan.gdcu.Vista.Gestor.Detalles.java
private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed ok = true;//from w ww . j a v a 2 s .co m String mensaje = ""; UrlValidator validador = new UrlValidator(); if (!txtFuente.getText().trim().isEmpty()) { if (!validador.isValid(txtFuente.getText())) { mensaje += "La url fuente no es valida\n"; } else { fuente = txtFuente.getText(); } } if (!txtDescarga.getText().trim().isEmpty()) { if (!validador.isValid(txtDescarga.getText())) { mensaje += "La url descarga no es valida\n"; } else { descarga = txtDescarga.getText(); } } if (!mensaje.equals("")) { JOptionPane.showMessageDialog(this, mensaje, "Revisa los campos", JOptionPane.ERROR_MESSAGE); return; } this.dispose(); }
From source file:net.sf.keystore_explorer.gui.CreateApplicationGui.java
private static boolean checkJreVersion() { JavaVersion actualJreVersion = null; try {// w w w.j a va 2 s . co m actualJreVersion = JavaVersion.getJreVersion(); } catch (VersionException ex) { String message = res.getString("CreateApplicationGui.NoParseJreVersion.message"); System.err.println(message); JOptionPane.showMessageDialog(new JFrame(), message, KSE.getApplicationName(), JOptionPane.ERROR_MESSAGE); return false; } if (actualJreVersion.compareTo(MIN_JRE_VERSION) < 0) { String message = MessageFormat.format(res.getString("CreateApplicationGui.MinJreVersionReq.message"), actualJreVersion, MIN_JRE_VERSION); System.err.println(message); JOptionPane.showMessageDialog(new JFrame(), message, KSE.getApplicationName(), JOptionPane.ERROR_MESSAGE); return false; } return true; }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDRResultsController.java
/** * @param pdfFile/*ww w .j a va 2 s . com*/ */ @Override protected void tryToCreateFile(File pdfFile) { try { boolean success = pdfFile.createNewFile(); if (success) { doseResponseController.showMessage("Pdf Report successfully created!", "Report created", JOptionPane.INFORMATION_MESSAGE); } else { Object[] options = { "Yes", "No", "Cancel" }; int showOptionDialog = JOptionPane.showOptionDialog(null, "File already exists. Do you want to replace it?", "", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[2]); // if YES, user wants to delete existing file and replace it if (showOptionDialog == 0) { boolean delete = pdfFile.delete(); if (!delete) { return; } // if NO, returns already existing file } else if (showOptionDialog == 1) { return; } } } catch (IOException ex) { doseResponseController.showMessage("Unexpected error: " + ex.getMessage() + ".", "Unexpected error", JOptionPane.ERROR_MESSAGE); return; } try (FileOutputStream fileOutputStream = new FileOutputStream(pdfFile)) { // actually create PDF file createPdfFile(fileOutputStream); } catch (IOException ex) { doseResponseController.showMessage("Unexpected error: " + ex.getMessage() + ".", "Unexpected error", JOptionPane.ERROR_MESSAGE); } }
From source file:net.sf.jabref.JabRefGUI.java
private void openWindow() { // Perform checks and changes for users with a preference set from an older JabRef version. PreferencesMigrations.replaceAbstractField(); PreferencesMigrations.upgradeSortOrder(); PreferencesMigrations.upgradeFaultyEncodingStrings(); // This property is set to make the Mac OSX Java VM move the menu bar to the top of the screen if (OS.OS_X) { System.setProperty("apple.laf.useScreenMenuBar", "true"); }/*from w ww . j a v a 2 s . co m*/ // Set antialiasing on everywhere. This only works in JRE >= 1.5. // Or... it doesn't work, period. // TODO test and maybe remove this! I found this commented out with no additional info ( payload@lavabit.com ) // Enabled since JabRef 2.11 beta 4 System.setProperty("swing.aatext", "true"); // Default is "on". // "lcd" instead of "on" because of http://wiki.netbeans.org/FaqFontRendering and http://docs.oracle.com/javase/6/docs/technotes/guides/2d/flags.html#aaFonts System.setProperty("awt.useSystemAAFontSettings", "lcd"); // look and feel. This MUST be the first thing to do before loading any Swing-specific code! setLookAndFeel(); // If the option is enabled, open the last edited databases, if any. if (!isBlank && Globals.prefs.getBoolean(JabRefPreferences.OPEN_LAST_EDITED) && (Globals.prefs.get(JabRefPreferences.LAST_EDITED) != null)) { openLastEditedDatabase(); } GUIGlobals.init(); GUIGlobals.currentFont = new Font(Globals.prefs.get(JabRefPreferences.FONT_FAMILY), Globals.prefs.getInt(JabRefPreferences.FONT_STYLE), Globals.prefs.getInt(JabRefPreferences.FONT_SIZE)); LOGGER.debug("Initializing frame"); JabRefGUI.mainFrame = new JabRefFrame(); // Add all loaded databases to the frame: boolean first = true; if (!loaded.isEmpty()) { for (Iterator<ParserResult> i = loaded.iterator(); i.hasNext();) { ParserResult pr = i.next(); if (new LastFocusedTabPreferences(Globals.prefs).hadLastFocus(pr.getFile())) { first = true; } if (pr.isInvalid()) { failed.add(pr); i.remove(); } else if (!pr.isPostponedAutosaveFound()) { if (pr.toOpenTab()) { // things to be appended to an opened tab should be done after opening all tabs // add them to the list toOpenTab.add(pr); } else { JabRefGUI.getMainFrame().addParserResult(pr, first); first = false; } } else { i.remove(); postponed.add(pr.getFile()); } } } // finally add things to the currently opened tab for (ParserResult pr : toOpenTab) { JabRefGUI.getMainFrame().addParserResult(pr, first); first = false; } // Start auto save timer: if (Globals.prefs.getBoolean(JabRefPreferences.AUTO_SAVE)) { Globals.startAutoSaveManager(JabRefGUI.getMainFrame()); } // If we are set to remember the window location, we also remember the maximised // state. This needs to be set after the window has been made visible, so we // do it here: if (Globals.prefs.getBoolean(JabRefPreferences.WINDOW_MAXIMISED)) { JabRefGUI.getMainFrame().setExtendedState(JFrame.MAXIMIZED_BOTH); } JabRefGUI.getMainFrame().setVisible(true); if (Globals.prefs.getBoolean(JabRefPreferences.WINDOW_MAXIMISED)) { JabRefGUI.getMainFrame().setExtendedState(JFrame.MAXIMIZED_BOTH); } for (ParserResult pr : failed) { String message = "<html>" + Localization.lang("Error opening file '%0'.", pr.getFile().getName()) + "<p>" + pr.getErrorMessage() + "</html>"; JOptionPane.showMessageDialog(JabRefGUI.getMainFrame(), message, Localization.lang("Error opening file"), JOptionPane.ERROR_MESSAGE); } if (Globals.prefs.getBoolean(JabRefPreferences.DISPLAY_KEY_WARNING_DIALOG_AT_STARTUP)) { int i = 0; for (ParserResult pr : loaded) { ParserResultWarningDialog.showParserResultWarningDialog(pr, JabRefGUI.getMainFrame(), i++); } } // After adding the databases, go through each and see if // any post open actions need to be done. For instance, checking // if we found new entry types that can be imported, or checking // if the database contents should be modified due to new features // in this version of JabRef. // Note that we have to check whether i does not go over getBasePanelCount(). // This is because importToOpen might have been used, which adds to // loaded, but not to getBasePanelCount() for (int i = 0; (i < loaded.size()) && (i < JabRefGUI.getMainFrame().getBasePanelCount()); i++) { ParserResult pr = loaded.get(i); BasePanel panel = JabRefGUI.getMainFrame().getBasePanelAt(i); OpenDatabaseAction.performPostOpenActions(panel, pr, true); } LOGGER.debug("Finished adding panels"); // If any database loading was postponed due to an autosave, schedule them // for handing now: if (!postponed.isEmpty()) { AutosaveStartupPrompter asp = new AutosaveStartupPrompter(JabRefGUI.getMainFrame(), postponed); SwingUtilities.invokeLater(asp); } if (!loaded.isEmpty()) { new FocusRequester(JabRefGUI.getMainFrame().getCurrentBasePanel().getMainTable()); } }
From source file:de.unidue.inf.is.ezdl.gframedl.EzDL.java
private static void checkJavaVersion() { Set<String> lafNames = new HashSet<String>(); for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { lafNames.add(info.getName());/* ww w. j av a2 s .com*/ } if (!lafNames.contains("Nimbus")) { String message = "<html>Please install a recent version of Java 1.6 (http://www.java.com)!<br /><br /> Detected version: " + System.getProperty("java.version"); JOptionPane.showMessageDialog(null, message, "No appropriate Java version detected!", JOptionPane.ERROR_MESSAGE); System.exit(0); } }
From source file:net.sf.jabref.exporter.SaveDatabaseAction.java
private boolean saveDatabase(File file, boolean selectedOnly, Charset encoding) throws SaveException { SaveSession session;/*from www . j a va 2 s. c o m*/ frame.block(); try { SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs) .withEncoding(encoding); BibDatabaseWriter databaseWriter = new BibDatabaseWriter(); if (selectedOnly) { session = databaseWriter.savePartOfDatabase(panel.getBibDatabaseContext(), prefs, panel.getSelectedEntries()); } else { session = databaseWriter.saveDatabase(panel.getBibDatabaseContext(), prefs); } panel.registerUndoableChanges(session); } catch (UnsupportedCharsetException ex2) { JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + Localization .lang("Character encoding '%0' is not supported.", encoding.displayName()), Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE); throw new SaveException("rt"); } catch (SaveException ex) { if (ex == SaveException.FILE_LOCKED) { throw ex; } if (ex.specificEntry()) { // Error occured during processing of // be. Highlight it: int row = panel.mainTable.findEntry(ex.getEntry()); int topShow = Math.max(0, row - 3); panel.mainTable.setRowSelectionInterval(row, row); panel.mainTable.scrollTo(topShow); panel.showEntry(ex.getEntry()); } else { LOGGER.error("Problem saving file", ex); } JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + ".\n" + ex.getMessage(), Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE); throw new SaveException("rt"); } finally { frame.unblock(); } boolean commit = true; if (!session.getWriter().couldEncodeAll()) { FormBuilder builder = FormBuilder.create() .layout(new FormLayout("left:pref, 4dlu, fill:pref", "pref, 4dlu, pref")); JTextArea ta = new JTextArea(session.getWriter().getProblemCharacters()); ta.setEditable(false); builder.add(Localization.lang("The chosen encoding '%0' could not encode the following characters:", session.getEncoding().displayName())).xy(1, 1); builder.add(ta).xy(3, 1); builder.add(Localization.lang("What do you want to do?")).xy(1, 3); String tryDiff = Localization.lang("Try different encoding"); int answer = JOptionPane.showOptionDialog(frame, builder.getPanel(), Localization.lang("Save database"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[] { Localization.lang("Save"), tryDiff, Localization.lang("Cancel") }, tryDiff); if (answer == JOptionPane.NO_OPTION) { // The user wants to use another encoding. Object choice = JOptionPane.showInputDialog(frame, Localization.lang("Select encoding"), Localization.lang("Save database"), JOptionPane.QUESTION_MESSAGE, null, Encodings.ENCODINGS_DISPLAYNAMES, encoding); if (choice == null) { commit = false; } else { Charset newEncoding = Charset.forName((String) choice); return saveDatabase(file, selectedOnly, newEncoding); } } else if (answer == JOptionPane.CANCEL_OPTION) { commit = false; } } try { if (commit) { session.commit(file); panel.setEncoding(encoding); // Make sure to remember which encoding we used. } else { session.cancel(); } } catch (SaveException e) { int ans = JOptionPane.showConfirmDialog(null, Localization.lang("Save failed during backup creation") + ". " + Localization.lang("Save without backup?"), Localization.lang("Unable to create backup"), JOptionPane.YES_NO_OPTION); if (ans == JOptionPane.YES_OPTION) { session.setUseBackup(false); session.commit(file); panel.setEncoding(encoding); } else { commit = false; } } return commit; }