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:de.dakror.villagedefense.util.SaveHandler.java
public static void sendScore() { try {/*from w ww . j ava 2 s . c o m*/ if (isWorldScorePosted(Game.currentGame.worldCreated)) { JOptionPane.showMessageDialog(null, "Du hast deinen Punktestand auf dieser Karte bereits in der Bestenliste platziert!", "Bereits platziert!", JOptionPane.ERROR_MESSAGE); return; } String response = Helper .getURLContent(new URL("http://dakror.de/villagedefense/api/scores.php?USERNAME=" + urlencode(CFG.USERNAME) + "&SCORE=" + Game.currentGame.getPlayerScore())); System.out.println(response); if (!response.equals("false")) { JOptionPane.showMessageDialog(null, "Dein Punktestand wurde erfolgreich in der Bestenliste platziert.", "Platzieren erfolgreich!", JOptionPane.INFORMATION_MESSAGE); addWorldScorePosted(Game.currentGame.worldCreated); Game.currentGame.scoreSent = true; } else JOptionPane.showMessageDialog(null, "Dein Punktestand konnte nicht in der Bestenliste platziert werden!", "Platzieren fehlgeschlagen!", JOptionPane.ERROR_MESSAGE); } catch (Exception e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(null, "Dein Punktestand konnte nicht in der Bestenliste platziert werden!\nMglicherweise bist du nicht mit dem Internet verbunden.", "Platzieren fehlgeschlagen!", JOptionPane.ERROR_MESSAGE); } }
From source file:br.usp.poli.lta.cereda.wsn2spa.Editor.java
private void showException(String title, Exception exception) { String html = String.format("<html><body style=\"width:250px\">%s</body></html>", exception.getMessage()); JOptionPane.showMessageDialog(this, html, title, JOptionPane.ERROR_MESSAGE); }
From source file:de.pavloff.spark4knime.jsnippet.ui.JarListPanel.java
@SuppressWarnings("null") private void onJarURLAdd() { DefaultListModel<String> model = (DefaultListModel<String>) m_addJarList.getModel(); Set<String> hash = new HashSet<>(Collections.list(model.elements())); String input = "knime://knime.workflow/example.jar"; boolean valid; do {//from w w w .ja v a 2 s. co m input = JOptionPane.showInputDialog(this, "Enter a \"knime:\" URL to a JAR file", input); if (StringUtils.isEmpty(input)) { valid = true; } else { URL url; try { url = new URL(input); File file = FileUtil.getFileFromURL(url); CheckUtils.checkArgument(file != null, "Could not resolve to local file"); CheckUtils.checkArgument(file.exists(), "File does not exists; location resolved to\n%s", file.getAbsolutePath()); valid = true; } catch (MalformedURLException | IllegalArgumentException mfe) { JOptionPane.showMessageDialog(this, "Invalid URL\n" + mfe.getMessage(), "Error parsing URL", JOptionPane.ERROR_MESSAGE); valid = false; continue; } } } while (!valid); if (!StringUtils.isEmpty(input) && hash.add(input)) { model.addElement(input); } }
From source file:graphic.ihm.dialog.createperso.DialCreatePerso.java
/** * @param evt/*from w w w . j a va 2s. c o m*/ */ private void createActionPerformed(ActionEvent evt) { // on verifie MessageResolver msgRes = new MessageResolver(); Boolean isValid = verifyValue(); if (isValid) { creerPerso(); this.setVisible(false); MainFrame.main(null); parent.setVisible(false); } else { JOptionPane.showMessageDialog(null, msgRes.getValueFromCode("dial.create.perso.no.data"), "Erreur", JOptionPane.ERROR_MESSAGE); } }
From source file:fi.smaa.jsmaa.gui.JSMAAMainFrame.java
public void open() { if (!checkSaveCurrentModel()) { return;/*w w w . jav a 2 s . co m*/ } FileLoadDialog dialog = new FileLoadDialog(this, "jsmaa", "JSMAA model files") { @Override public void doAction(String path, String extension) { try { File file = new File(path); InputStream fis = new FileInputStream(file); SMAAModel loadedModel = JSMAABinding.readModel(new BufferedInputStream(fis)); fis.close(); modelManager.setModel(loadedModel); modelManager.setModelFile(file); } catch (FileNotFoundException e) { JOptionPane.showMessageDialog(JSMAAMainFrame.this, "Error loading model: " + e.getMessage(), "Load error", JOptionPane.ERROR_MESSAGE); } catch (InvalidModelVersionException e) { showErrorIncompatibleModel(path, "file contains a an incompatible JSMAA model version " + e.getVersion() + ".\nOnly versions until " + SMAAModel.MODELVERSION + " supported.\nTo open the file, upgrade to a newer version of JSMAA (www.smaa.fi)"); } catch (Exception e) { e.printStackTrace(); showErrorIncompatibleModel(path, "file doesn't dontain a JSMAA model"); } } }; dialog.loadActions(); }
From source file:cz.moz.ctmanager.main.MainAppFrame.java
private void detailsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_detailsButtonActionPerformed int selectedRow = contactTable.getSelectedRow(); if (selectedRow == -1) { JOptionPane.showMessageDialog(this, "Nothing Selected", "Error Message", JOptionPane.ERROR_MESSAGE); } else {//from www.j a v a 2s .co m DetailsFrame detailsFrame = new DetailsFrame(); int selectedContactID = (int) contactTable.getValueAt(contactTable.getSelectedRow(), 0); Contact contact = contactsDao.getContact(selectedContactID); detailsFrame.setContact(contact); detailsFrame.initializeComponents(); detailsFrame.setVisible(true); } }
From source file:de.main.sessioncreator.DesktopApplication1View.java
@Action public void showHelpPdf() { File f = new File(System.getProperty("user.dir") + "/SessionCreatorHelp.pdf"); try {//from w w w . j ava2s . com Desktop.getDesktop().open(f); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error during open the Help:\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:lab4.YouQuiz.java
private void switchToQuizMode() { JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false);// ww w . j a va 2 s.c o m backButton.setFocusable(false); toolbar.add(backButton); toolbar.setAlignmentX(0); backButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { contentPanel.setQuestion(questionsArray.get(--questionIndex)); forwardButton.setEnabled(true); if (questionIndex - 1 < 0) { backButton.setEnabled(false); } updateAnswerForm(); } }); forwardButton.setFocusable(false); toolbar.add(forwardButton); toolbar.setAlignmentX(0); forwardButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { contentPanel.setQuestion(questionsArray.get(++questionIndex)); backButton.setEnabled(true); if (questionsArray.size() == questionIndex + 1) { forwardButton.setEnabled(false); } updateAnswerForm(); } }); speakButton.setFocusable(false); toolbar.add(speakButton); toolbar.setAlignmentX(0); speakButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { Audio audio = Audio.getInstance(); InputStream sound = null; try { sound = audio.getAudio(questionsArray.get(questionIndex).getQuestion(), Language.ENGLISH); } catch (IOException ex) { Logger.getLogger(YouQuiz.class.getName()).log(Level.SEVERE, null, ex); } try { audio.play(sound); } catch (JavaLayerException ex) { Logger.getLogger(YouQuiz.class.getName()).log(Level.SEVERE, null, ex); } } }); refreshButton.setFocusable(false); toolbar.add(refreshButton); toolbar.setAlignmentX(0); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { shuffleQuestions(); questionIndex = 0; backButton.setEnabled(false); if (questionsArray.size() == 1) { forwardButton.setEnabled(false); } else { forwardButton.setEnabled(true); } contentPanel.setQuestion(questionsArray.get(questionIndex)); updateAnswerForm(); } }); micButton.setFocusable(false); toolbar.add(micButton); toolbar.setAlignmentX(0); micButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { GSpeechDuplex dup = new GSpeechDuplex(); dup.addResponseListener(new GSpeechResponseListener() { @Override public void onResponse(GoogleResponse gr) { if (questionsArray.get(questionIndex).checkAnswer(gr.getResponse())) { JOptionPane.showMessageDialog(null, "Thats Great, Correct Answer", "Excellent", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Oops! '" + gr.getResponse() + "' is a wrong Answer. Its '" + questionsArray.get(questionIndex).getAnswer().get(0) + "'", "Sorry", JOptionPane.ERROR_MESSAGE); } } }); Microphone mic = new Microphone(FLACFileWriter.FLAC); File file = new File("CRAudioTest.flac"); try { mic.captureAudioToFile(file); Thread.sleep(5000); mic.close(); byte[] data = Files.readAllBytes(mic.getAudioFile().toPath()); dup.recognize(data, (int) mic.getAudioFormat().getSampleRate()); mic.getAudioFile().delete(); } catch (LineUnavailableException | InterruptedException | IOException ex) { } } }); contentPanel = new ContentPanel(); contentPanel.add(Box.createRigidArea(new Dimension(0, 10))); contentPanel.add(toolbar, BorderLayout.NORTH); contentPanel.add(Box.createRigidArea(new Dimension(0, 50))); contentPanel.add(contentPanel.questionLabel); add(contentPanel, BorderLayout.CENTER); if (questionsArray.isEmpty()) { refreshButton.setEnabled(false); backButton.setEnabled(false); forwardButton.setEnabled(false); speakButton.setEnabled(false); } else { questionIndex = 0; backButton.setEnabled(false); if (questionsArray.size() == 1) { forwardButton.setEnabled(false); } contentPanel.setQuestion(questionsArray.get(questionIndex)); contentPanel.add(Box.createRigidArea(new Dimension(0, 20))); contentPanel.add(contentPanel.answerPanel); contentPanel.add(Box.createRigidArea(new Dimension(0, 10))); contentPanel.add(contentPanel.checkButton); updateAnswerForm(); } }
From source file:hermes.renderers.DefaultMessageRenderer.java
/** * Show the TextMessage in a JTextArea./* ww w . j a va 2 s .c om*/ * * @param textMessage * @return * @throws JMSException */ protected JComponent handleTextMessage(final TextMessage textMessage) throws JMSException { // // Show the text in a JTextArea, you can edit the message in place and // then drop it onto another queue/topic. final String text = textMessage.getText(); final JTextArea textPane = new JTextArea(); // final CharBuffer bytes = CharBuffer.wrap(text.subSequence(0, // text.length())) ; // final JTextArea textPane = new MyTextArea(new PlainDocument(new // MappedStringContent(bytes))) ; textPane.setEditable(false); textPane.setFont(Font.decode("Monospaced-PLAIN-12")); textPane.setLineWrap(true); textPane.setWrapStyleWord(true); textPane.append(text); textPane.getDocument().addDocumentListener(new DocumentListener() { public void doChange() { try { textMessage.setText(textPane.getText()); } catch (JMSException e) { JOptionPane.showMessageDialog(textPane, "Unable to update the TextMessage: " + e.getMessage(), "Error modifying message content", JOptionPane.ERROR_MESSAGE); try { textPane.setText(textMessage.getText()); } catch (JMSException e1) { log.error(e1.getMessage(), e1); } textPane.setEditable(false); textPane.getDocument().removeDocumentListener(this); } } @Override public void changedUpdate(DocumentEvent arg0) { doChange(); } @Override public void insertUpdate(DocumentEvent arg0) { doChange(); } @Override public void removeUpdate(DocumentEvent arg0) { doChange(); } }); textPane.setCaretPosition(0); return textPane; }
From source file:com.akman.enjoyfood.SelectPrinters.java
private void btnContinueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnContinueActionPerformed if (tblPrinters.getSelectedRow() != -1) { int row = tblPrinters.getSelectedRow(); if (tblPrinters.getValueAt(row, 1) == "Offline") { JOptionPane.showMessageDialog(null, "Printer is Offline", "Offine error", JOptionPane.ERROR_MESSAGE); } else {// w ww . ja va 2 s . c om } Printer printer = (Printer) tblPrinters.getValueAt(row, 0); try { String propFileName = "config.properties"; PropertiesConfiguration prop = new PropertiesConfiguration(propFileName); prop.setProperty("Printer", printer.getName()); prop.save(); } catch (ConfigurationException ex) { } this.dispose(); if (order == null) { } else { order.setPrinter(printer); order.run(); } } }