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:org.jdal.swing.TableEditor.java
/** * Delete selected table rows using persistent service *///from w ww.j a v a 2 s .co m @SuppressWarnings("unchecked") public void delete() { if (onDelete()) { int[] rows = table.getSelectedRows(); for (int i : rows) { T model = (T) tableModel.getList().get(table.convertRowIndexToModel(i)); try { service.delete(model); tableModel.getList().remove(model); } catch (DataAccessException dae) { String errorMsg = messageSource.getMessage("TableEditor.objectInUse", new Object[] { model.toString() }, Locale.getDefault()); JOptionPane.showMessageDialog(getPanel(), errorMsg, "Error", JOptionPane.ERROR_MESSAGE); } } tableModel.fireTableChanged(); } }
From source file:net.sf.jabref.external.push.PushToEmacs.java
@Override public void operationCompleted(BasePanel panel) { if (couldNotConnect) { JOptionPane.showMessageDialog(panel.frame(), "<HTML>" + Localization.lang("Could not connect to a running gnuserv process. Make sure that " + "Emacs or XEmacs is running,<BR>and that the server has been started " + "(by running the command 'server-start'/'gnuserv-start').") + "</HTML>", Localization.lang("Error"), JOptionPane.ERROR_MESSAGE); } else if (couldNotCall) { JOptionPane.showMessageDialog(panel.frame(), Localization.lang("Could not run the gnuclient/emacsclient program. Make sure you have " + "the emacsclient/gnuclient program installed and available in the PATH."), Localization.lang("Error"), JOptionPane.ERROR_MESSAGE); } else {/*from w w w.j av a 2 s.com*/ super.operationCompleted(panel); } }
From source file:dotaSoundEditor.Controls.EditorPanel.java
protected File promptUserForNewFile(String wavePath) { JFileChooser chooser = new JFileChooser(new File(UserPrefs.getInstance().getWorkingDirectory())); FileNameExtensionFilter filter = new FileNameExtensionFilter("MP3s and WAVs", "mp3", "wav"); chooser.setAcceptAllFileFilterUsed((false)); chooser.setFileFilter(filter);/*from w w w . j a v a 2 s . c o m*/ chooser.setMultiSelectionEnabled(false); int chooserRetVal = chooser.showOpenDialog(chooser); if (chooserRetVal == JFileChooser.APPROVE_OPTION) { DefaultMutableTreeNode selectedFile = (DefaultMutableTreeNode) getTreeNodeFromWavePath(wavePath); Path chosenFile = Paths.get(chooser.getSelectedFile().getAbsolutePath()); //Strip caps and spaces out of filenames. The item sound parser seems to have trouble with them. String destFileName = chosenFile.getFileName().toString().toLowerCase().replace(" ", "_"); Path destPath = Paths.get(installDir, "/dota/sound/" + getCustomSoundPathString() + destFileName); UserPrefs.getInstance().setWorkingDirectory(chosenFile.getParent().toString()); try { new File(destPath.toString()).mkdirs(); Files.copy(chosenFile, destPath, StandardCopyOption.REPLACE_EXISTING); String waveString = selectedFile.getUserObject().toString(); int startIndex = -1; int endIndex = -1; if (waveString.contains("\"wave\"")) { startIndex = Utility.nthOccurrence(selectedFile.getUserObject().toString(), '\"', 2); endIndex = Utility.nthOccurrence(selectedFile.getUserObject().toString(), '\"', 3); } else //Some wavestrings don't have the "wave" at the beginning for some reason { startIndex = Utility.nthOccurrence(selectedFile.getUserObject().toString(), '\"', 0); endIndex = Utility.nthOccurrence(selectedFile.getUserObject().toString(), '\"', 1); } String waveStringFilePath = waveString.substring(startIndex, endIndex + 1); waveString = waveString.replace(waveStringFilePath, "\"" + getCustomSoundPathString() + destFileName + "\""); selectedFile.setUserObject(waveString); //Write out modified tree to scriptfile. ScriptParser parser = new ScriptParser(this.currentTreeModel); String scriptString = getCurrentScriptString(); Path scriptPath = Paths.get(scriptString); parser.writeModelToFile(scriptPath.toString()); //Update UI ((DefaultMutableTreeNode) currentTree.getLastSelectedPathComponent()).setUserObject(waveString); ((DefaultTreeModel) currentTree.getModel()) .nodeChanged((DefaultMutableTreeNode) currentTree.getLastSelectedPathComponent()); JOptionPane.showMessageDialog(this, "Sound file successfully replaced."); } catch (IOException ex) { JOptionPane.showMessageDialog(null, "Unable to replace sound.\nDetails: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } return null; }
From source file:com.firmansyah.imam.sewa.kendaraan.FormLogin.java
private void btnLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoginActionPerformed String username = inputUsername.getText(); String passwordTemp = inputPassword.getText(); String password;//from ww w . ja va 2 s . c om password = DigestUtils.md5Hex(passwordTemp); if (username.isEmpty() || password.isEmpty()) { JOptionPane.showMessageDialog(this, "Username / Password Tidak Boleh Kosong", "Informasi", JOptionPane.ERROR_MESSAGE); } else { String url = Path.serverURL + "/user/login/" + username + "/" + password; getDataURL dataurl = new getDataURL(); try { String data = dataurl.getData(url); System.out.println(data); if (data.equals("1")) { JOptionPane.showMessageDialog(this, "Login Berhasil", "Informasi", JOptionPane.INFORMATION_MESSAGE); this.dispose(); System.out.println("Panggil Form Sewa"); // memanggil form Sewa FormSewa callForm = new FormSewa(); callForm.setLocationRelativeTo(null); callForm.setVisible(true); } else if (data.equals("2")) { JOptionPane.showMessageDialog(this, "Username Telah di Nonaktifkan", "Informasi", JOptionPane.ERROR_MESSAGE); inputUsername.setText(""); inputPassword.setText(""); } else { JOptionPane.showMessageDialog(this, "Username / Password Salah", "Informasi", JOptionPane.ERROR_MESSAGE); inputUsername.setText(""); inputPassword.setText(""); } } catch (IOException ex) { Logger.getLogger(FormLogin.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:hr.fer.zemris.vhdllab.platform.manager.simulation.DefaultSimulationManager.java
@Override public void simulate(File file) { Validate.notNull(file, "File can't be null"); if (!file.getType().isSimulatable()) { logger.info(file.getName() + " isn't simulatable"); return;//from w w w .ja v a 2 s . c o m } Project project = file.getProject(); EditorManager em = editorManagerFactory.getAllAssociatedWithProject(project); boolean shouldSimulate = em.save(true, SaveContext.SIMULATE_AFTER_SAVE); if (shouldSimulate) { Result result; try { result = simulator.simulate(file.getId()); } catch (SimulatorTimeoutException e) { String message = localizationSource.getMessage("simulator.simulate.timout", new Object[] { file.getName() }); result = new Result(Collections.singletonList(message)); } catch (NoAvailableProcessException e) { String message = localizationSource.getMessage("simulator.simulate.no.processes", new Object[] { file.getName() }); result = new Result(Collections.singletonList(message)); } catch (CompilationException e) { if (e.getMessage().endsWith("Neither compilation nor simulation can be run.")) { Frame frame = Application.instance().getActiveWindow().getControl(); JOptionPane.showMessageDialog(frame, e.getMessage(), "Couldn't run simulation", JOptionPane.ERROR_MESSAGE); return; } throw e; } lastSimulatedFile = file; fireSimulated(file, result); openSimulationEditor(file, result); logger.info(localizationSource.getMessage(SIMULATED_MESSAGE, new Object[] { file.getName(), project.getName() })); } }
From source file:net.launchpad.jabref.plugins.ZentralSearch.java
private BibtexDatabase importZentralblattEntries(String key, OutputPrinter status) { String url = getZentralblattUrl(); HttpURLConnection zentralblattConnection = null; try {//from www . ja v a2s.co m log.debug("Zentralblatt URL: " + url); URL ZBUrl = new URL(url); String query = constructQuery(key); if (StringUtils.isBlank(query)) { log.error("Search entry was empty."); status.showMessage("Please select or enter keyword"); return null; } zentralblattConnection = (HttpURLConnection) ZBUrl.openConnection(); zentralblattConnection.setDoOutput(true); // Triggers POST. zentralblattConnection.setRequestProperty("Accept-Charset", CHARSET); zentralblattConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + CHARSET); zentralblattConnection.setRequestProperty("User-Agent", "Jabref"); OutputStream output = null; try { output = zentralblattConnection.getOutputStream(); output.write(query.getBytes(CHARSET)); } finally { if (output != null) try { output.close(); } catch (IOException e) { log.debug(e.getMessage(), e); } } Set<String> bibtex = fetchBibtexEntries(IOUtils.toString(zentralblattConnection.getInputStream())); return makeBibtexDB(bibtex); } catch (IOException e) { log.error("IO-Problem: " + e.getMessage(), e); status.showMessage(Globals.lang("An Exception ocurred while accessing '%0'", url) + "\n\n" + e.getLocalizedMessage(), Globals.lang(getKeyName()), JOptionPane.ERROR_MESSAGE); } catch (RuntimeException e) { log.error("General Problem: " + e.getMessage(), e); status.showMessage( Globals.lang("An Error occurred while fetching from Mathematisches Zentralblatt (%0):", new String[] { url }) + "\n\n" + e.getMessage(), Globals.lang(getKeyName()), JOptionPane.ERROR_MESSAGE); } return null; }
From source file:com.microsoftopentechnologies.intellij.forms.TableForm.java
public TableForm() { final TableForm form = this; this.setResizable(false); this.setModal(true); this.setTitle("Create new table"); this.setContentPane(mainPanel); createButton.setEnabled(false);/*from w w w . jav a 2 s .c om*/ tableNameTextField.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent keyEvent) { super.keyTyped(keyEvent); createButton.setEnabled(!tableNameTextField.getText().isEmpty()); } }); final PermissionItem[] tablePermissions = PermissionItem.getTablePermissions(); insertPermisssionComboBox.setModel(new DefaultComboBoxModel(tablePermissions)); deletePermissionComboBox.setModel(new DefaultComboBoxModel(tablePermissions)); updatePermissionComboBox.setModel(new DefaultComboBoxModel(tablePermissions)); readPermissionComboBox.setModel(new DefaultComboBoxModel(tablePermissions)); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { form.setVisible(false); form.dispose(); } }); createButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { try { TablePermissions tablePermissions = new TablePermissions(); tablePermissions.setDelete( ((PermissionItem) deletePermissionComboBox.getSelectedItem()).getType()); tablePermissions.setUpdate( ((PermissionItem) updatePermissionComboBox.getSelectedItem()).getType()); tablePermissions .setRead(((PermissionItem) readPermissionComboBox.getSelectedItem()).getType()); tablePermissions.setInsert( ((PermissionItem) insertPermisssionComboBox.getSelectedItem()).getType()); final String tableName = tableNameTextField.getText().trim(); if (!tableName.matches("^[A-Za-z][A-Za-z0-9_]+")) { JOptionPane.showMessageDialog(form, "Invalid table name. Table name must start with a letter, \n" + "contain only letters, numbers, and underscores.", "Error creating the table", JOptionPane.ERROR_MESSAGE); return; } int tableNameIndex = -1; if (existingTableNames != null) { tableNameIndex = Iterables.indexOf(existingTableNames, new Predicate<String>() { @Override public boolean apply(String name) { return tableName.equalsIgnoreCase(name); } }); } if (tableNameIndex != -1) { JOptionPane.showMessageDialog(form, "Invalid table name. A table with that name already exists in this service.", "Error creating the table", JOptionPane.ERROR_MESSAGE); return; } form.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (editingTable == null) { AzureRestAPIManager.getManager().createTable(subscriptionId, serviceName, tableName, tablePermissions); } else { AzureRestAPIManager.getManager().updateTable(subscriptionId, serviceName, tableName, tablePermissions); } if (afterSave != null) afterSave.run(); form.setVisible(false); form.dispose(); form.setCursor(Cursor.getDefaultCursor()); } catch (Throwable e) { form.setCursor(Cursor.getDefaultCursor()); UIHelper.showException("Error creating table", e); } } }); } }); }
From source file:de.badw.strauss.glyphpicker.controller.alltab.TeiLoadWorker.java
/** * Triggers parsing of the XML input stream. * * @param is the input stream/*from w ww .j av a 2 s. co m*/ * @return the resulting GlyphDefinition list */ public List<GlyphDefinition> parseXmlSax(InputStream is) { TeiXmlHandler handler = new TeiXmlHandler(dataSource); try { parser.parse(is, handler); handler.resolveReferences(); return handler.getGlyphDefinitions(); } catch (SAXException e) { JOptionPane.showMessageDialog(null, e.toString(), i18n.getString("TeiLoadWorker.xmlParsingError"), JOptionPane.ERROR_MESSAGE); } catch (IOException e) { JOptionPane.showMessageDialog(null, e.toString(), i18n.getString("TeiLoadWorker.xmlParsingError"), JOptionPane.ERROR_MESSAGE); } catch (TeiXmlHandler.RecursionException e) { JOptionPane.showMessageDialog(null, e.getMessage(), i18n.getString("TeiLoadWorker.xmlParsingError"), JOptionPane.ERROR_MESSAGE); } return null; }
From source file:components.IntegerEditor.java
/** * Lets the user know that the text they entered is * bad. Returns true if the user elects to revert to * the last good value. Otherwise, returns false, * indicating that the user wants to continue editing. *//*from www. j av a 2 s .com*/ protected boolean userSaysRevert() { Toolkit.getDefaultToolkit().beep(); ftf.selectAll(); Object[] options = { "Edit", "Revert" }; int answer = JOptionPane.showOptionDialog(SwingUtilities.getWindowAncestor(ftf), "The value must be an integer between " + minimum + " and " + maximum + ".\n" + "You can either continue editing " + "or revert to the last valid value.", "Invalid Text Entered", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[1]); if (answer == 1) { //Revert! ftf.setValue(ftf.getValue()); return true; } return false; }
From source file:br.com.bgslibrary.gui.MainFrame.java
private void execute() { if (autoclearCheckBox.isSelected()) logTextPane.setText(""); stop();//from www.ja v a 2s .c o m if (Command.validade()) try { if (epRunning == false) { ep = new ExternalProcess(); externalProcessThread = new Thread(ep); externalProcessThread.start(); epRunning = true; appTabbedPane.setSelectedIndex(3); } } catch (Exception ex) { ex.printStackTrace(); } else JOptionPane.showMessageDialog(this, "Check parameters!", "Alert", JOptionPane.ERROR_MESSAGE); }