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:net.sf.profiler4j.console.Console.java
public void error(String message, Throwable t) { showMessageDialog(mainFrame, message + "\nMessage: " + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); }
From source file:net.sf.jabref.importer.AppendDatabaseAction.java
private void openIt(boolean importEntries, boolean importStrings, boolean importGroups, boolean importSelectorWords) { if (filesToOpen.isEmpty()) { return;/*from w ww. j a v a 2 s.co m*/ } for (File file : filesToOpen) { try { Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, file.getPath()); // Should this be done _after_ we know it was successfully opened? Charset encoding = Globals.prefs.getDefaultEncoding(); ParserResult pr = OpenDatabaseAction.loadDatabase(file, encoding); AppendDatabaseAction.mergeFromBibtex(frame, panel, pr, importEntries, importStrings, importGroups, importSelectorWords); panel.output(Localization.lang("Imported from database") + " '" + file.getPath() + "'"); } catch (IOException | KeyCollisionException ex) { LOGGER.warn("Could not open database", ex); JOptionPane.showMessageDialog(panel, ex.getMessage(), Localization.lang("Open database"), JOptionPane.ERROR_MESSAGE); } } }
From source file:edu.ucla.stat.SOCR.chart.demo.PowerTransformationFamilyChart.java
protected void createActionComponents(JToolBar toolBar) { super.createActionComponents(toolBar); JButton button;/*from w ww.j ava 2 s . c o m*/ /**************** wiki Tab ****************/ Action linkAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { try { //popInfo("SOCRChart: About", new java.net.URL("http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_PowerTransformFamily_Graphs"), "SOCR: Power Transform Graphing Activity"); parentApplet.getAppletContext().showDocument(new java.net.URL( "http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_PowerTransformFamily_Graphs"), "SOCR: Power Transform Graphing Activity"); } catch (MalformedURLException Exc) { JOptionPane.showMessageDialog(null, Exc, "MalformedURL Error", JOptionPane.ERROR_MESSAGE); Exc.printStackTrace(); } } }; button = toolBar.add(linkAction); button.setText(" WIKI_Activity "); button.setToolTipText("Press this Button to go to SOCR_POWER_Activity wiki page"); }
From source file:com.moneydance.modules.features.importlist.io.FileAdmin.java
public void checkValidBaseDirectory() { final File baseDirectory = this.getBaseDirectory(); if (baseDirectory == null) { return;/* ww w. ja v a 2s . c om*/ } if (!this.directoryValidator.isValidDirectory(baseDirectory)) { LOG.warning(String.format("Could not open directory %s", baseDirectory.getAbsolutePath())); final String errorMessage = this.localizable.getErrorMessageBaseDirectory(baseDirectory.getName()); final Object errorLabel = new JLabel(errorMessage); JOptionPane.showMessageDialog(null, // no parent component errorLabel, null, // no title JOptionPane.ERROR_MESSAGE); this.directoryChooser.reset(); } }
From source file:dk.i2m.netbeans.modules.ldapexplorer.ui.ExplorerTopComponent.java
@Override public void componentClosed() { result.removeLookupListener(this); if (this.server != null) { try {//from w w w . jav a2s .c om this.server.disconnect(); } catch (ConnectionException ex) { JOptionPane.showMessageDialog(null, ex.getMessage(), "An error occurred", JOptionPane.ERROR_MESSAGE); } } }
From source file:es.uvigo.ei.sing.adops.views.TextFileViewer.java
public TextFileViewer(final File file) { super(new BorderLayout()); this.file = file; // TEXT AREA//from ww w . j a va2s. c om this.textArea = new JTextArea(TextFileViewer.loadFile(file)); this.textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, this.textArea.getFont().getSize())); this.textArea.setLineWrap(true); this.textArea.setWrapStyleWord(true); this.textArea.setEditable(false); this.highlightPatiner = new DefaultHighlighter.DefaultHighlightPainter(Color.YELLOW); // OPTIONS PANEL final JPanel panelOptions = new JPanel(new BorderLayout()); final JPanel panelOptionsEast = new JPanel(new FlowLayout()); final JPanel panelOptionsWest = new JPanel(new FlowLayout()); final JCheckBox chkLineWrap = new JCheckBox("Line wrap", true); final JButton btnChangeFont = new JButton("Change Font"); final JLabel lblSearch = new JLabel("Search"); this.txtSearch = new JTextField(); this.chkRegularExpression = new JCheckBox("Reg. exp.", true); final JButton btnSearch = new JButton("Search"); final JButton btnClear = new JButton("Clear"); this.txtSearch.setColumns(12); // this.txtSearch.setOpaque(true); panelOptionsEast.add(btnChangeFont); panelOptionsEast.add(chkLineWrap); panelOptionsWest.add(lblSearch); panelOptionsWest.add(this.txtSearch); panelOptionsWest.add(this.chkRegularExpression); panelOptionsWest.add(btnSearch); panelOptionsWest.add(btnClear); if (FastaUtils.isFasta(file)) { panelOptionsWest.add(new JSeparator()); final JButton btnExport = new JButton("Export..."); panelOptionsWest.add(btnExport); btnExport.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { new ExportDialog(file).setVisible(true); } catch (Exception e1) { JOptionPane.showMessageDialog(Workbench.getInstance().getMainFrame(), "Error reading fasta file: " + e1.getMessage(), "Export Error", JOptionPane.ERROR_MESSAGE); } } }); } panelOptions.add(panelOptionsWest, BorderLayout.WEST); panelOptions.add(panelOptionsEast, BorderLayout.EAST); this.fontChooser = new JFontChooser(); this.add(new JScrollPane(this.textArea), BorderLayout.CENTER); this.add(panelOptions, BorderLayout.NORTH); chkLineWrap.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textArea.setLineWrap(chkLineWrap.isSelected()); } }); btnChangeFont.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changeFont(); } }); this.textArea.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { TextFileViewer.this.wasModified = true; } @Override public void insertUpdate(DocumentEvent e) { TextFileViewer.this.wasModified = true; } @Override public void changedUpdate(DocumentEvent e) { TextFileViewer.this.wasModified = true; } }); this.textArea.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { if (TextFileViewer.this.wasModified) { try { FileUtils.write(TextFileViewer.this.file, TextFileViewer.this.textArea.getText()); TextFileViewer.this.wasModified = false; } catch (IOException e1) { e1.printStackTrace(); } } } }); final ActionListener alSearch = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateSearch(); } }; txtSearch.addActionListener(alSearch); btnSearch.addActionListener(alSearch); btnClear.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { clearSearch(); } }); }
From source file:net.sf.jabref.external.DownloadExternalFile.java
/** * Start a download.//from w w w.java 2 s . c o m * * @param callback The object to which the filename should be reported when download * is complete. */ public void download(URL url, final DownloadCallback callback) throws IOException { String res = url.toString(); String mimeType; // First of all, start the download itself in the background to a temporary file: final File tmp = File.createTempFile("jabref_download", "tmp"); tmp.deleteOnExit(); URLDownload udl = MonitoredURLDownload.buildMonitoredDownload(frame, url); try { // TODO: what if this takes long time? // TODO: stop editor dialog if this results in an error: mimeType = udl.determineMimeType(); // Read MIME type } catch (IOException ex) { JOptionPane.showMessageDialog(frame, Localization.lang("Invalid URL") + ": " + ex.getMessage(), Localization.lang("Download file"), JOptionPane.ERROR_MESSAGE); LOGGER.info("Error while downloading " + "'" + res + "'", ex); return; } final URL urlF = url; final URLDownload udlF = udl; JabRefExecutorService.INSTANCE.execute(() -> { try { udlF.downloadToFile(tmp); } catch (IOException e2) { dontShowDialog = true; if ((editor != null) && editor.isVisible()) { editor.setVisible(false, false); } JOptionPane.showMessageDialog(frame, Localization.lang("Invalid URL") + ": " + e2.getMessage(), Localization.lang("Download file"), JOptionPane.ERROR_MESSAGE); LOGGER.info("Error while downloading " + "'" + urlF + "'", e2); return; } // Download finished: call the method that stops the progress bar etc.: SwingUtilities.invokeLater(DownloadExternalFile.this::downloadFinished); }); Optional<ExternalFileType> suggestedType = Optional.empty(); if (mimeType != null) { LOGGER.debug("MIME Type suggested: " + mimeType); suggestedType = ExternalFileTypes.getInstance().getExternalFileTypeByMimeType(mimeType); } // Then, while the download is proceeding, let the user choose the details of the file: String suffix; if (suggestedType.isPresent()) { suffix = suggestedType.get().getExtension(); } else { // If we didn't find a file type from the MIME type, try based on extension: suffix = getSuffix(res); if (suffix == null) { suffix = ""; } suggestedType = ExternalFileTypes.getInstance().getExternalFileTypeByExt(suffix); } String suggestedName = getSuggestedFileName(suffix); List<String> fDirectory = databaseContext.getFileDirectory(); String directory; if (fDirectory.isEmpty()) { directory = null; } else { directory = fDirectory.get(0); } final String suggestDir = directory == null ? System.getProperty("user.home") : directory; File file = new File(new File(suggestDir), suggestedName); FileListEntry entry = new FileListEntry("", file.getCanonicalPath(), suggestedType); editor = new FileListEntryEditor(frame, entry, true, false, databaseContext); editor.getProgressBar().setIndeterminate(true); editor.setOkEnabled(false); editor.setExternalConfirm(closeEntry -> { File f = directory == null ? new File(closeEntry.link) : expandFilename(directory, closeEntry.link); if (f.isDirectory()) { JOptionPane.showMessageDialog(frame, Localization.lang("Target file cannot be a directory."), Localization.lang("Download file"), JOptionPane.ERROR_MESSAGE); return false; } if (f.exists()) { return JOptionPane.showConfirmDialog(frame, Localization.lang("'%0' exists. Overwrite file?", f.getName()), Localization.lang("Download file"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION; } else { return true; } }); if (dontShowDialog) { return; } else { editor.setVisible(true, false); } // Editor closed. Go on: if (editor.okPressed()) { File toFile = directory == null ? new File(entry.link) : expandFilename(directory, entry.link); String dirPrefix; if (directory == null) { dirPrefix = null; } else { if (directory.endsWith(System.getProperty("file.separator"))) { dirPrefix = directory; } else { dirPrefix = directory + System.getProperty("file.separator"); } } try { boolean success = FileUtil.copyFile(tmp, toFile, true); if (!success) { // OOps, the file exists! LOGGER.error("File already exists! DownloadExternalFile.download()"); } // If the local file is in or below the main file directory, change the // path to relative: if ((directory != null) && entry.link.startsWith(directory) && (entry.link.length() > dirPrefix.length())) { entry = new FileListEntry(entry.description, entry.link.substring(dirPrefix.length()), entry.type); } callback.downloadComplete(entry); } catch (IOException ex) { LOGGER.warn("Problem downloading file", ex); } if (!tmp.delete()) { LOGGER.info("Cannot delete temporary file"); } } else { // Canceled. Just delete the temp file: if (downloadFinished && !tmp.delete()) { LOGGER.info("Cannot delete temporary file"); } } }
From source file:net.sourceforge.atunes.kernel.modules.process.AudioFileTransferProcess.java
@Override protected boolean runProcess() { boolean errors = false; File destination = new File(getDestination()); long bytesTransferred = 0; boolean ignoreAllErrors = false; addInfoLog(StringUtils.getString("Transferring ", this.filesToTransfer.size(), " files to ", destination)); for (Iterator<AudioFile> it = this.filesToTransfer.iterator(); it.hasNext() && !cancel;) { AudioFile file = it.next();//ww w . j a v a 2 s . c o m final List<Exception> thrownExceptions = new ArrayList<Exception>(); File transferredFile = transferAudioFile(destination, file, thrownExceptions); filesTransferred.add(transferredFile); if (!thrownExceptions.isEmpty()) { for (Exception e : thrownExceptions) { addErrorLog(e); } if (!ignoreAllErrors) { try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { userSelectionWhenErrors = (String) VisualHandler.getInstance().showMessage( StringUtils.getString(LanguageTool.getString("ERROR"), ": ", thrownExceptions.get(0).getMessage()), LanguageTool.getString("ERROR"), JOptionPane.ERROR_MESSAGE, new String[] { LanguageTool.getString("IGNORE"), LanguageTool.getString("IGNORE_ALL"), LanguageTool.getString("CANCEL") }); } }); } catch (InterruptedException e1) { // Do nothing } catch (InvocationTargetException e1) { // Do nothing } if (LanguageTool.getString("IGNORE").equals(userSelectionWhenErrors)) { // Do nothing, let execution continue } else if (LanguageTool.getString("IGNORE_ALL").equals(userSelectionWhenErrors)) { // Don't display more error messages ignoreAllErrors = true; } else if (LanguageTool.getString("CANCEL").equals(userSelectionWhenErrors)) { // Only in this case set errors to true to force refresh in other case errors = true; // Don't continue break; } } } // Add size to bytes transferred bytesTransferred += file.getFile().length(); setCurrentProgress(bytesTransferred); } addInfoLog("Transfer process done"); return !errors; }
From source file:jpad.MainEditor.java
public void openFile_OSX_Nix() { isOpen = true;//from w ww . j av a2s . c o m FilenameFilter awtFilter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { String lowercaseName = name.toLowerCase(); if (lowercaseName.endsWith(".txt")) return true; else return false; } }; FileDialog fd = new FileDialog(this, "Open Text File", FileDialog.LOAD); fd.setFilenameFilter(awtFilter); fd.setVisible(true); if (fd.getFile() == null) return; else curFile = fd.getDirectory() + fd.getFile(); //TODO: actually open the file try (FileInputStream inputStream = new FileInputStream(curFile)) { String allText = org.apache.commons.io.IOUtils.toString(inputStream); mainTextArea.setText(allText); } catch (Exception ex) { JOptionPane.showMessageDialog(this, ex.getMessage(), "Error While Reading", JOptionPane.ERROR_MESSAGE); } JRootPane root = this.getRootPane(); root.putClientProperty("Window.documentFile", new File(curFile)); root.putClientProperty("Window.documentModified", Boolean.FALSE); hasChanges = false; hasSavedToFile = true; this.setTitle(String.format("JPad - %s", curFile)); isOpen = false; }
From source file:com.devbury.mkremote.server.QuickLaunchServiceImpl.java
public void executeAbsolute(String file) { final File f = newFile(file); if (isSupported()) { logger.debug("Opening {}", file); open(f);/*from w w w. ja va2s . c o m*/ } else { logger.debug("Desktop is not supported"); new Thread() { @Override public void run() { JOptionPane.showMessageDialog(null, "We are sorry but mkRemote is unable to start applications on your platform", "Could Not Launch " + f.getAbsolutePath(), JOptionPane.ERROR_MESSAGE); } }.start(); } }