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:com.aw.swing.mvp.ui.msg.MessageDisplayerImpl.java
/** * Show a message used to inform to the user of something that happened * * @param message/* w w w .j av a2 s . c o m*/ */ public static void showErrorMessage(Component parentContainer, String message) { ProcessMsgBlocker.instance().removeMessage(); JOptionPane.showMessageDialog(parentContainer, message, GENERIC_MESSAGE_TITLE, JOptionPane.ERROR_MESSAGE); }
From source file:com.stefanbrenner.droplet.ui.actions.OpenFileAction.java
protected void open(final boolean asTemplate) { int returnVal = fileChooser.showOpenDialog(getFrame()); if (returnVal == JFileChooser.APPROVE_OPTION) { try {/* w w w . java 2 s. c o m*/ File file = fileChooser.getSelectedFile(); if (!file.exists()) { JOptionPane.showMessageDialog(getFrame(), Messages.getString("SaveFileAction.fileNotFound"), //$NON-NLS-1$ Messages.getString("SaveFileAction.fileNotFound"), //$NON-NLS-1$ JOptionPane.ERROR_MESSAGE); open(false); return; } BufferedReader in = new BufferedReader(new FileReader(file)); String xml = IOUtils.toString(in); in.close(); JAXBHelper jaxbHelper = new JAXBHelper(); IDroplet droplet = jaxbHelper.fromXml(xml, IDroplet.class); if (asTemplate) { // reset droplet droplet.reset(); getDropletContext().setFile(null); } else { getDropletContext().setFile(file); } // set droplet to context getDropletContext().setDroplet(droplet); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopComponentsHelper.java
public static int convertNotificationType(com.haulmont.cuba.gui.components.Frame.NotificationType type) { switch (type) { case WARNING: case WARNING_HTML: return JOptionPane.WARNING_MESSAGE; case ERROR:/* www. ja v a 2 s . c o m*/ case ERROR_HTML: return JOptionPane.ERROR_MESSAGE; case HUMANIZED: case HUMANIZED_HTML: return JOptionPane.INFORMATION_MESSAGE; case TRAY: case TRAY_HTML: return JOptionPane.WARNING_MESSAGE; default: return JOptionPane.PLAIN_MESSAGE; } }
From source file:dbseer.gui.chart.DBSeerChartRefreshWorker.java
@Override protected String doInBackground() throws Exception { long delay;// www . j a v a 2 s. co m long timeSlept; while (this.run) { try { delay = DBSeerGUI.liveMonitorRefreshRate * 1000; timeSlept = 0; while (timeSlept < delay) { timeSlept += 250; Thread.sleep(250); if (!this.run) { return null; } } if (!this.run) { return null; } StatisticalPackageRunner runner = DBSeerGUI.runner; boolean isLoadSuccess = false; try { runner.eval("plotter = Plotter;"); isLoadSuccess = dataset.loadDataset(true); if (isLoadSuccess) { runner.eval("[mvGrouped mvUngrouped] = load_mv2(" + dataset.getUniqueVariableName() + ".header," + dataset.getUniqueVariableName() + ".monitor," + dataset.getUniqueVariableName() + ".averageLatency," + dataset.getUniqueVariableName() + ".percentileLatency," + dataset.getUniqueVariableName() + ".transactionCount," + dataset.getUniqueVariableName() + ".diffedMonitor," + dataset.getUniqueVariableName() + ".statementStat);"); runner.eval("plotter.mv = mvUngrouped;"); } } catch (Exception e) { JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } if (isLoadSuccess) { for (DBSeerChart chart : charts) { if (chart.getName().equalsIgnoreCase("TransactionMix")) { DefaultPieDataset newDataset = DBSeerChartFactory.getPieDataset(chart.getName(), dataset); chart.setPieDataset(newDataset); publish(chart); } else if (chart.getName().equalsIgnoreCase("Custom")) { XYSeriesCollection newDataset = DBSeerChartFactory .getCustomXYSeriesCollection(chart.getXAxisName(), chart.getYAxisName()); chart.setXYDataset(newDataset); publish(chart); } else { XYSeriesCollection newDataset = DBSeerChartFactory .getXYSeriesCollection(chart.getName(), dataset); chart.setXYDataset(newDataset); publish(chart); } } } } catch (InterruptedException e) { e.printStackTrace(); } } return null; }
From source file:net.openbyte.gui.CreateProjectFrame.java
private void button1ActionPerformed(ActionEvent e) { if (!(Launch.nameToSolution.get(textField1.getText()) == null)) { JOptionPane.showMessageDialog(this, "Project has already been created.", "Error", JOptionPane.ERROR_MESSAGE); return;// ww w .jav a 2 s . c o m } ModificationAPI modificationAPI = ModificationAPI.MINECRAFT_FORGE; String apiName = (String) comboBox1.getSelectedItem(); if (apiName.equals("MCP")) { modificationAPI = ModificationAPI.MCP; } if (apiName.equals("Bukkit")) { modificationAPI = ModificationAPI.BUKKIT; } MinecraftVersion minecraftVersion = MinecraftVersion.BOUNTIFUL_UPDATE; if (((String) comboBox2.getSelectedItem()).equals("1.7.10")) { minecraftVersion = MinecraftVersion.THE_UPDATE_THAT_CHANGED_THE_WORLD; } if (modificationAPI == ModificationAPI.MCP) { minecraftVersion = MinecraftVersion.COMBAT_UPDATE; String version = (String) comboBox2.getSelectedItem(); if (version.equals("1.8.9")) { minecraftVersion = MinecraftVersion.BOUNTIFUL_UPDATE; } if (version.equals("1.7.10")) { minecraftVersion = MinecraftVersion.THE_UPDATE_THAT_CHANGED_THE_WORLD; } } if (modificationAPI == ModificationAPI.BUKKIT) { minecraftVersion = MinecraftVersion.COMBAT_UPDATE; } this.version = minecraftVersion; this.api = modificationAPI; setVisible(false); //JOptionPane.showMessageDialog(this, "We're working on setting up the project. When we are ready, a window will show up.", "Working on project creation", JOptionPane.INFORMATION_MESSAGE); this.projectName = textField1.getText(); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { doOperations(); return null; } }; monitor.setMillisToPopup(0); monitor.setMillisToDecideToPopup(0); monitor.setProgress(1); worker.execute(); if (monitor.isCanceled()) { projectFolder.delete(); new File(Files.WORKSPACE_DIRECTORY, projectName + ".openproj").delete(); return; } }
From source file:de.dakror.virtualhub.client.dialog.ChooseCatalogDialog.java
public static void show(ClientFrame frame, final JSONArray data) { final JDialog dialog = new JDialog(frame, "Katalog whlen", true); dialog.setSize(400, 300);/*from w w w .ja v a 2 s. c o m*/ dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { Client.currentClient.disconnect(); System.exit(0); } }); JPanel contentPane = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); dialog.setContentPane(contentPane); DefaultListModel dlm = new DefaultListModel(); for (int i = 0; i < data.length(); i++) { try { dlm.addElement(data.getJSONObject(i).getString("name")); } catch (JSONException e) { e.printStackTrace(); } } final JList catalogs = new JList(dlm); catalogs.setDragEnabled(false); catalogs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane jsp = new JScrollPane(catalogs, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); jsp.setPreferredSize(new Dimension(396, 200)); contentPane.add(jsp); JPanel mods = new JPanel(new GridLayout(1, 2)); mods.setPreferredSize(new Dimension(50, 22)); mods.add(new JButton(new AbstractAction("+") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { String name = JOptionPane.showInputDialog(dialog, "Bitte geben Sie den Namen des neuen Katalogs ein.", "Katalog hinzufgen", JOptionPane.PLAIN_MESSAGE); if (name != null && name.length() > 0) { DefaultListModel dlm = (DefaultListModel) catalogs.getModel(); for (int i = 0; i < dlm.getSize(); i++) { if (dlm.get(i).toString().equals(name)) { JOptionPane.showMessageDialog(dialog, "Es existert bereits ein Katalog mit diesem Namen!", "Katalog bereits vorhanden!", JOptionPane.ERROR_MESSAGE); actionPerformed(e); return; } } try { dlm.addElement(name); JSONObject o = new JSONObject(); o.put("name", name); o.put("sources", new JSONArray()); o.put("tags", new JSONArray()); data.put(o); Client.currentClient.sendPacket(new Packet0Catalogs(data)); } catch (Exception e1) { e1.printStackTrace(); } } } })); mods.add(new JButton(new AbstractAction("-") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { if (catalogs.getSelectedIndex() != -1) { if (JOptionPane.showConfirmDialog(dialog, "Sind Sie sicher, dass Sie diesen\r\nKatalog unwiderruflich lschen wollen?", "Katalog lschen", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { DefaultListModel dlm = (DefaultListModel) catalogs.getModel(); data.remove(catalogs.getSelectedIndex()); dlm.remove(catalogs.getSelectedIndex()); try { Client.currentClient.sendPacket(new Packet0Catalogs(data)); } catch (IOException e1) { e1.printStackTrace(); } } } } })); contentPane.add(mods); JLabel l = new JLabel(""); l.setPreferredSize(new Dimension(396, 14)); contentPane.add(l); JSeparator sep = new JSeparator(JSeparator.HORIZONTAL); sep.setPreferredSize(new Dimension(396, 10)); contentPane.add(sep); JPanel buttons = new JPanel(new GridLayout(1, 2)); buttons.setPreferredSize(new Dimension(396, 22)); buttons.add(new JButton(new AbstractAction("Abbrechen") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { Client.currentClient.disconnect(); System.exit(0); } })); buttons.add(new JButton(new AbstractAction("Katalog whlen") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { if (catalogs.getSelectedIndex() != -1) { try { Client.currentClient .setCatalog(new Catalog(data.getJSONObject(catalogs.getSelectedIndex()))); Client.currentClient.frame.setTitle("- " + Client.currentClient.getCatalog().getName()); dialog.dispose(); } catch (JSONException e1) { e1.printStackTrace(); } } } })); dialog.add(buttons); dialog.setLocationRelativeTo(frame); dialog.setResizable(false); dialog.setVisible(true); }
From source file:com.tiempometa.muestradatos.JReadTags.java
private void startReadingButtonActionPerformed(ActionEvent e) { if (ReaderContext.isUsbConnected()) { if (ReaderContext.isUsbReading()) { ReaderContext.stopReading(); startReadingButton.setText("Iniciar la lectura"); } else {/* w w w .j a v a 2s. c o m*/ try { ReaderContext.startReading(); startReadingButton.setText("Detener la lectura"); } catch (ReaderException e1) { JOptionPane.showMessageDialog(this, "No se pudo iniciar la lectura.", "Iniciar lectura", JOptionPane.ERROR_MESSAGE); } } } }
From source file:com.peter.javaautoupdater.JavaAutoUpdater.java
public static void run(String ftpHost, int ftpPort, String ftpUsername, String ftpPassword, boolean isLocalPassiveMode, boolean isRemotePassiveMode, String basePath, String softwareName, String args[]) {/* w w w. j av a2 s . c o m*/ System.out.println("jarName=" + jarName); for (String arg : args) { if (arg.toLowerCase().trim().equals("-noautoupdate")) { return; } } JavaAutoUpdater.basePath = basePath; JavaAutoUpdater.softwareName = softwareName; JavaAutoUpdater.args = args; if (!jarName.endsWith(".jar") || jarName.startsWith("JavaAutoUpdater-")) { if (isDebug) { jarName = "test.jar"; } else { return; } } JProgressBarDialog d = new JProgressBarDialog(new JFrame(), "Auto updater", true); d.progressBar.setIndeterminate(true); d.progressBar.setStringPainted(true); d.progressBar.setString("Updating"); // d.addCancelEventListener(this); Thread longRunningThread = new Thread() { public void run() { d.progressBar.setString("checking latest version"); System.out.println("checking latest version"); FTPClient ftp = new FTPClient(); try { ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); ftp.connect(ftpHost, ftpPort); int reply = ftp.getReplyCode(); System.out.println("reply=" + reply + ", " + FTPReply.isPositiveCompletion(reply)); if (!FTPReply.isPositiveCompletion(reply)) { ftp.disconnect(); JOptionPane.showMessageDialog(null, "FTP server refused connection", "error", JOptionPane.ERROR_MESSAGE); } d.progressBar.setString("connected to ftp"); System.out.println("connected to ftp"); boolean success = ftp.login(ftpUsername, ftpPassword); if (!success) { ftp.disconnect(); JOptionPane.showMessageDialog(null, "FTP login fail, can't update software", "error", JOptionPane.ERROR_MESSAGE); } if (isLocalPassiveMode) { ftp.enterLocalPassiveMode(); } if (isRemotePassiveMode) { ftp.enterRemotePassiveMode(); } FTPFile[] ftpFiles = ftp.listFiles(basePath, new FTPFileFilter() { @Override public boolean accept(FTPFile file) { if (file.getName().startsWith(softwareName)) { return true; } else { return false; } } }); if (ftpFiles.length > 0) { FTPFile targetFile = ftpFiles[ftpFiles.length - 1]; System.out.println("targetFile : " + targetFile.getName() + " , " + targetFile.getSize() + "!=" + new File(jarName).length()); if (!targetFile.getName().equals(jarName) || targetFile.getSize() != new File(jarName).length()) { int r = JOptionPane.showConfirmDialog(null, "Confirm to update to " + targetFile.getName(), "Question", JOptionPane.YES_NO_OPTION); if (r == JOptionPane.YES_OPTION) { //ftp.enterRemotePassiveMode(); d.progressBar.setString("downloading " + targetFile.getName()); ftp.setFileType(FTP.BINARY_FILE_TYPE); ftp.setFileTransferMode(FTP.BINARY_FILE_TYPE); d.progressBar.setIndeterminate(false); d.progressBar.setMaximum(100); CopyStreamAdapter streamListener = new CopyStreamAdapter() { @Override public void bytesTransferred(long totalBytesTransferred, int bytesTransferred, long streamSize) { int percent = (int) (totalBytesTransferred * 100 / targetFile.getSize()); d.progressBar.setValue(percent); } }; ftp.setCopyStreamListener(streamListener); try (FileOutputStream fos = new FileOutputStream(targetFile.getName())) { ftp.retrieveFile(basePath + "/" + targetFile.getName(), fos); } catch (IOException e) { e.printStackTrace(); } d.progressBar.setString("restarting " + targetFile.getName()); restartApplication(targetFile.getName()); } } } ftp.logout(); ftp.disconnect(); } catch (Exception ex) { ex.printStackTrace(); } } }; d.thread = longRunningThread; d.setVisible(true); }
From source file:net.schweerelos.parrot.CombinedParrotApp.java
/** * @param args/* w w w . j ava 2 s .co m*/ */ @SuppressWarnings("static-access") public static void main(String[] args) { CommandLineParser parser = new PosixParser(); // create the Options Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("help") .withDescription("Shows usage information and quits the program").create("h")); options.addOption( OptionBuilder.withLongOpt("datafile").withDescription("The file with instances to use (required)") .hasArg().withArgName("file").isRequired().create("f")); options.addOption(OptionBuilder.withLongOpt("properties") .withDescription("Properties file to use. Default: " + System.getProperty("user.home") + File.separator + ".digital-parrot" + File.separator + "parrot.properties") .hasArg().withArgName("prop").create("p")); try { // parse the command line arguments CommandLine line = parser.parse(options, args); if (line.hasOption("h")) { // this is only executed when all required options are present _and_ the help option is specified! printHelp(options); return; } String datafile = line.getOptionValue("f"); if (!datafile.startsWith("file:") || !datafile.startsWith("http:")) { datafile = "file:" + datafile; } String propertiesPath = System.getProperty("user.home") + File.separator + ".digital-parrot" + File.separator + "parrot.properties"; if (line.hasOption("p")) { propertiesPath = line.getOptionValue("p"); } final Properties properties = new Properties(); File propertiesFile = new File(propertiesPath); if (propertiesFile.exists() && propertiesFile.canRead()) { try { properties.load(new FileReader(propertiesFile)); } catch (FileNotFoundException e) { e.printStackTrace(System.err); System.exit(1); } catch (IOException e) { e.printStackTrace(System.err); System.exit(1); } } final String url = datafile; // we need a "final" var for the anonymous class SwingUtilities.invokeLater(new Runnable() { public void run() { CombinedParrotApp inst = null; try { inst = new CombinedParrotApp(properties); inst.loadModel(url); } catch (Exception e) { JOptionPane.showMessageDialog(null, "There has been an error while starting the program.\nThe program will exit now.", APP_TITLE + " Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(System.err); System.exit(1); } if (inst != null) { inst.setLocationRelativeTo(null); inst.setVisible(true); } } }); } catch (ParseException exp) { printHelp(options); } }
From source file:com.emental.mindraider.ui.panels.ConceptAttachmentsJPanel.java
public void init() { JPanel pp;/*ww w. j a v a 2 s . c o m*/ setBorder(new TitledBorder(Messages.getString("ConceptJPanel.attachments"))); setLayout(new BorderLayout()); // button pp = new JPanel(); pp.setLayout(new GridLayout(3, 1)); JButton jbutton = new JButton("", IconsRegistry.getImageIcon("attach.png")); jbutton.setToolTipText(Messages.getString("ConceptJPanel.attachLocalResourceToConcept")); jbutton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // some concept must be selected - select graph node according // to the selected concept =-> touchgraph // method needed if (conceptJPanel.getConceptResource() == null) { JOptionPane.showMessageDialog(MindRaider.mainJFrame, Messages.getString("ConceptJPanel.attachResourceWarning"), Messages.getString("ConceptJPanel.attachmentError"), JOptionPane.ERROR_MESSAGE); return; } new AttachmentJDialog(conceptJPanel.getConceptResource()); } }); pp.add(jbutton); // @todo edit resource description // jbutton=new JButton("",IconsRegistry.getImageIcon("attachLink.png")); // jbutton.setToolTipText("Attach web resource to concept"); // jbutton.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // } // }); // pp.add(jbutton); // attach another concept/folder/resource... - perhaps extra frame with // radio jbutton = new JButton("", IconsRegistry.getImageIcon("launch.png")); jbutton.setToolTipText(Messages.getString("ConceptJPanel.showAttachment")); jbutton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (attachmentsTableModel.attachments != null) { if (attachments.getSelectedRow() == -1) { JOptionPane.showMessageDialog(MindRaider.mainJFrame, Messages.getString("ConceptJPanel.selectAttachmentToLaunch"), Messages.getString("ConceptJPanel.attachmentError"), JOptionPane.ERROR_MESSAGE); return; } String uri = attachmentsTableModel.attachments[attachments.getSelectedRow()].getUrl(); if (uri != null) { Node node = new Node(); node.setLabel(uri); node.setURL(uri); node.setType( MindRaider.spidersColorProfileRegistry.getCurrentProfile().getLiteralNodeType()); MindRaider.spidersGraph.handleDoubleSelect(node); } } } }); pp.add(jbutton); jbutton = new JButton("", IconsRegistry.getImageIcon("explorerDiscardSmall.png")); jbutton.setToolTipText(Messages.getString("ConceptJPanel.removeAttachment")); pp.add(jbutton); jbutton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (attachmentsTableModel.attachments != null) { if (getAttachments().getSelectedRow() != -1) { logger.debug(Messages.getString("ConceptJPanel.removingAttachment", getAttachments().getSelectedRow())); String attachUrl = getAttachmentsTableModel().attachments[getAttachments().getSelectedRow()] .getUrl(); logger.debug(Messages.getString("ConceptJPanel.removingAttachmentUrl", attachUrl)); if (conceptJPanel.getConceptResource() != null) { // check, that selected node is type of literal // (helper on spiders graph) MindRaider.noteCustodian.removeAttachment( MindRaider.profile.getActiveOutlineUri().toString(), conceptJPanel.getConceptResource(), attachUrl); conceptJPanel.refresh(); MindRaider.spidersGraph.renderModel(); return; } } JOptionPane.showMessageDialog(MindRaider.mainJFrame, Messages.getString("ConceptJPanel.selectAttachmentToRemove"), Messages.getString("ConceptJPanel.attachmentError"), JOptionPane.ERROR_MESSAGE); } } }); add(pp, BorderLayout.EAST); // table attachmentsTableModel = new AttachmentsTableModel(); attachments = new JTable(attachmentsTableModel) { private static final long serialVersionUID = 1L; public String getToolTipText(MouseEvent e) { String tip = null; java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); AttachmentsTableModel model = (AttachmentsTableModel) getModel(); tip = Messages.getString("ConceptJPanel.attachmentUrl") + model.attachments[rowIndex].getUrl(); // You can omit this part if you know you don't // have any renderers that supply their own tool // tips. // tip = super.getToolTipText(e); return tip; } }; TableColumn column = attachments.getColumnModel().getColumn(0); column.setMaxWidth(50); attachments.setRowHeight(20); attachments.setAutoscrolls(true); attachments.setPreferredScrollableViewportSize(new Dimension(500, 70)); JScrollPane scrollPane = new JScrollPane(attachments); add(scrollPane, BorderLayout.CENTER); }