Example usage for javax.swing JOptionPane ERROR_MESSAGE

List of usage examples for javax.swing JOptionPane ERROR_MESSAGE

Introduction

In this page you can find the example usage for javax.swing JOptionPane ERROR_MESSAGE.

Prototype

int ERROR_MESSAGE

To view the source code for javax.swing JOptionPane ERROR_MESSAGE.

Click Source Link

Document

Used for error messages.

Usage

From source file:io.github.dsheirer.gui.SDRTrunk.java

/**
 * Initialize the contents of the frame.
 *///  ww w . ja va2 s  . co m
private void initGUI() {
    mMainGui.setLayout(new MigLayout("insets 0 0 0 0 ", "[grow,fill]", "[grow,fill]"));

    /**
     * Setup main JFrame window
     */
    mTitle = SystemProperties.getInstance().getApplicationName();
    mMainGui.setTitle(mTitle);
    mMainGui.setBounds(100, 100, 1280, 800);
    mMainGui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Set preferred sizes to influence the split
    mSpectralPanel.setPreferredSize(new Dimension(1280, 300));
    mControllerPanel.setPreferredSize(new Dimension(1280, 500));

    mSplitPane = new JideSplitPane(JideSplitPane.VERTICAL_SPLIT);
    mSplitPane.setDividerSize(5);
    mSplitPane.add(mSpectralPanel);
    mSplitPane.add(mControllerPanel);

    mBroadcastStatusVisible = SystemProperties.getInstance().get(PROPERTY_BROADCAST_STATUS_VISIBLE, false);

    //Show broadcast status panel when user requests - disabled by default
    if (mBroadcastStatusVisible) {
        mSplitPane.add(getBroadcastStatusPanel());
    }

    mMainGui.add(mSplitPane, "cell 0 0,span,grow");

    /**
     * Menu items
     */
    JMenuBar menuBar = new JMenuBar();
    mMainGui.setJMenuBar(menuBar);

    JMenu fileMenu = new JMenu("File");
    menuBar.add(fileMenu);

    JMenuItem logFilesMenu = new JMenuItem("Logs & Recordings");
    logFilesMenu.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            try {
                Desktop.getDesktop().open(getHomePath().toFile());
            } catch (Exception e) {
                mLog.error("Couldn't open file explorer");

                JOptionPane.showMessageDialog(mMainGui,
                        "Can't launch file explorer - files are located at: " + getHomePath().toString(),
                        "Can't launch file explorer", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    fileMenu.add(logFilesMenu);

    JMenuItem settingsMenu = new JMenuItem("Icon Manager");
    settingsMenu.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            mIconManager.showEditor(mMainGui);
        }
    });
    fileMenu.add(settingsMenu);

    fileMenu.add(new JSeparator());

    JMenuItem exitMenu = new JMenuItem("Exit");
    exitMenu.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            System.exit(0);
        }
    });

    fileMenu.add(exitMenu);

    JMenu viewMenu = new JMenu("View");

    viewMenu.add(new BroadcastStatusVisibleMenuItem(mControllerPanel));

    menuBar.add(viewMenu);

    JMenuItem screenCaptureItem = new JMenuItem("Screen Capture");

    screenCaptureItem.setMnemonic(KeyEvent.VK_C);
    screenCaptureItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.ALT_MASK));

    screenCaptureItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            try {
                Robot robot = new Robot();

                final BufferedImage image = robot.createScreenCapture(mMainGui.getBounds());

                SystemProperties props = SystemProperties.getInstance();

                Path capturePath = props.getApplicationFolder("screen_captures");

                if (!Files.exists(capturePath)) {
                    try {
                        Files.createDirectory(capturePath);
                    } catch (IOException e) {
                        mLog.error("Couldn't create 'screen_captures' " + "subdirectory in the "
                                + "SDRTrunk application directory", e);
                    }
                }

                String filename = TimeStamp.getTimeStamp("_") + "_screen_capture.png";

                final Path captureFile = capturePath.resolve(filename);

                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            ImageIO.write(image, "png", captureFile.toFile());
                        } catch (IOException e) {
                            mLog.error("Couldn't write screen capture to " + "file [" + captureFile.toString()
                                    + "]", e);
                        }
                    }
                });
            } catch (AWTException e) {
                mLog.error("Exception while taking screen capture", e);
            }
        }
    });

    menuBar.add(screenCaptureItem);
}

From source file:dotaSoundEditor.Controls.ItemPanel.java

private VPKEntry getItemScriptFile() {
    String internalScriptPath = "scripts/game_sounds_items.txt";
    File vpkFile = new File(vpkPath);
    VPKArchive vpk = new VPKArchive();
    try {/*ww w  . j a v a  2  s  .  c o m*/
        vpk.load(vpkFile);
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(this, "Error: Unable to open VPK file.\nDetails: " + ex.getMessage(),
                "Error opening VPK", JOptionPane.ERROR_MESSAGE);
        ex.printStackTrace();
        return null;
    }

    VPKEntry entry = vpk.getEntry(internalScriptPath);
    return entry;
}

From source file:homenetapp.HomeNetAppGui.java

private void startHomeNetApp() {

    this.addWindowListener(new java.awt.event.WindowAdapter() {

        public void windowClosing(java.awt.event.WindowEvent winEvt) {
            // Perhaps ask user if they want to save any unsaved files first.
            exit();/*from w  w  w. ja va2s.  co  m*/
        }
    });

    homenetapp.homenet.addPortListener(new homenet.PortListener() {

        ArrayList<String> local = new ArrayList<String>();
        ArrayList<String> remote = new ArrayList<String>();

        private boolean isRemote(String port) {
            return port.equals("xmlrpc");
        }

        public void portAdded(String port) {
            // System.out.println("portAddedEvent");
            if (isRemote(port)) {
                remote.add(port);
                remoteStatusLabel.setText("Connected");
            } else {
                local.add(port);
                localStatusLabel.setText("Connected");
            }
        }

        public void portRemoved(String port) {
            //System.out.println("portRemovedEvent");
            if (isRemote(port)) {
                remote.remove(port);
                if (remote.size() < 1) {
                    remoteStatusLabel.setText("Not Connected");
                }
            } else {
                local.remove(port);
                if (local.size() < 1) {
                    localStatusLabel.setText("Not Connected");
                }
            }
        }

        public void portSendingStart(String port) {
            // System.out.println("portSendingStartEvent");
            if (isRemote(port)) {
                remoteSendingLabel.setText("(X)");
            } else {
                localSendingLabel.setText("(X)");
            }
        }

        public void portSendingEnd(String port) {
            // System.out.println("portSendingEndEvent");
            if (isRemote(port)) {
                Thread delayThread = new Thread() {
                    public void run() {
                        try {
                            Thread.sleep(500);
                        } catch (Exception e) {
                        }
                        remoteSendingLabel.setText("( )");
                    }
                };
                delayThread.start();

            } else {
                Thread delayThread = new Thread() {
                    public void run() {
                        try {
                            Thread.sleep(500);
                        } catch (Exception e) {
                        }
                        localSendingLabel.setText("( )");
                    }
                };
                delayThread.start();

            }
        }

        public void portReceivingStart(String port) {
            //  System.out.println("portRecievingStartEvent");
            if (isRemote(port)) {
                remoteReceivingLabel.setText("(X)");
            } else {
                localReceivingLabel.setText("(X)");
            }
        }

        public void portReceivingEnd(String port) {
            //   System.out.println("portRecievingEndEvent");
            if (isRemote(port)) {
                Thread delayThread = new Thread() {
                    public void run() {
                        try {
                            Thread.sleep(500);
                        } catch (Exception e) {
                        }
                        remoteReceivingLabel.setText("( )");
                    }
                };
                delayThread.start();

            } else {
                Thread delayThread = new Thread() {
                    public void run() {
                        try {
                            Thread.sleep(500);
                        } catch (Exception e) {
                        }
                        localReceivingLabel.setText("( )");
                    }
                };
                delayThread.start();

            }
        }
    });

    try {
        homenetapp.start();
    } catch (Exception e) {
        //show popup and exit program
        javax.swing.JOptionPane.showMessageDialog(null, "Error: " + e.getMessage(), "Error",
                javax.swing.JOptionPane.ERROR_MESSAGE);
        System.err.println(e.getMessage());
    }

    loadSettings();

    SendPacketFrame.setLocationRelativeTo(null);

    homenetapp.homenet.addPacketListener(new homenet.PacketListener() {

        public void packetRecieved(homenet.Packet packet) {
            addPacketToList(packet);
        }
    });

    homenetapp.serialmanager.addListener(new SerialListener() {

        public void portAdded(String name) {
            //    System.out.println("portAddedEvent");

            javax.swing.JCheckBoxMenuItem serialPortCheckBox = new javax.swing.JCheckBoxMenuItem(name);

            serialPortCheckBox.addActionListener(new java.awt.event.ActionListener() {

                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    JCheckBoxMenuItem checkbox = (JCheckBoxMenuItem) evt.getSource();
                    if (checkbox.isSelected()) {
                        try {
                            homenetapp.serialmanager.activatePort(checkbox.getText());
                        } catch (Exception e) {
                            javax.swing.JOptionPane.showMessageDialog(null,
                                    "Port " + checkbox.getText() + " Error: " + e.getMessage(), "Error",
                                    javax.swing.JOptionPane.ERROR_MESSAGE);
                        }
                    } else {
                        homenetapp.serialmanager.deactivatePort(checkbox.getText());
                    }
                }
            });

            // serialPortCheckBox.setMnemonic(java.awt.event.KeyEvent.VK_1);
            menuItems.put(name, serialPortCheckBox);
            menuSerialPorts.add(serialPortCheckBox);

        }

        public void portRemoved(String name) {
            // System.out.println("portRemovedEvent");
            menuSerialPorts.remove(menuItems.get(name));
        }

        public void portActivated(String name) {
            //  System.out.println("portActivatedEvent");
            menuItems.get(name).setSelected(true);

        }

        public void portDeactivated(String name) {
            //  System.out.println("portDeactivatedEvent");
            menuItems.get(name).setSelected(false);
        }
    });

    try {
        homenetapp.serialmanager.start();
    } catch (Exception e) {
        javax.swing.JOptionPane.showMessageDialog(null, "Port Error: " + e.getMessage(), "Error",
                javax.swing.JOptionPane.ERROR_MESSAGE);
    }
}

From source file:com.tiempometa.muestradatos.JMuestraDatos.java

private void loadSettings() {
    readerStatusLabel.setText("Desconectado");
    readPowerLabel.setText("ND");
    writePowerLevel.setText("ND");
    rssiLevelLabel.setText("ND");
    try {//from   www  .j  a va2  s  .com
        ReaderContext.loadSettings();
        regionLabel.setText(ReaderContext.getSettings().getUsbRegion());
        readerPortLabel.setText(ReaderContext.getSettings().getUsbPort());
        databaseLabel.setText(ReaderContext.getSettings().getDatabaseName());
        boxIpAddressLabel.setText(ReaderContext.getSettings().getFoxberryReaderAddress());
        boxTypeLabel.setText(ReaderContext.getSettings().getTcpIpReaderType());
        preferredAntenaLabel.setText(ReaderContext.getSettings().getPreferredAntenna());
        preferredReaderLabel.setText(ReaderContext.getSettings().getPreferredReader());
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, "Error cargando configuracin " + e.getMessage(),
                "Error configuracin", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:org.cds06.speleograph.graph.ValueAxisEditor.java

/**
 * {@inheritDoc}/*from w w  w .j a  va2 s  .c o m*/
 */
protected void validateForm() {
    int maxValue = 0;
    int minValue = 0;
    try {
        maxValue = (int) (Double.parseDouble(maxField.getText()) + Double.parseDouble(maxModifier.getText()));
    } catch (NumberFormatException e) {
        JOptionPane.showMessageDialog(ValueAxisEditor.this.getParent(),
                "'" + maxField.getText() + "'" + " ou '" + maxModifier.getText() + "' n'est pas un nombre",
                "Erreur", JOptionPane.ERROR_MESSAGE);
    }
    try {
        minValue = (int) (Double.parseDouble(lowField.getText()) + Double.parseDouble(minModifier.getText()));
    } catch (NumberFormatException e) {
        JOptionPane.showMessageDialog(ValueAxisEditor.this.getParent(),
                "'" + lowField.getText() + "'" + " ou '" + minModifier.getText() + "' n'est pas un nombre",
                "Erreur", JOptionPane.ERROR_MESSAGE);
    }
    translateSlider.setValue(0);
    homotSlider.setValue(0);
    maxField.setText(String.valueOf(maxValue));
    lowField.setText(String.valueOf(minValue));

    firePropertyChange(FORM_VALIDATED_PROPERTY, null, this);
}

From source file:EditorPaneExample12.java

public void loadNewPage(Object page) {
    try {/*from   ww w .j a v  a 2 s .  c  o  m*/
        loadingPage = true;

        // Check if the new page and the old
        // page are the same.
        URL url;
        if (page instanceof URL) {
            url = (URL) page;
        } else {
            url = new URL((String) page);
        }

        urlCombo.setSelectedItem(page);

        URL loadedURL = pane.getPage();
        if (loadedURL != null && loadedURL.sameFile(url)) {
            return;
        }

        // Try to display the page
        urlCombo.setEnabled(false); // Disable input
        urlCombo.paintImmediately(0, 0, urlCombo.getSize().width, urlCombo.getSize().height);
        setCursor(waitCursor); // Busy cursor
        loadingState.setText("Loading...");
        loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height);
        loadedType.setText("");
        loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);

        timeLabel.setText("");
        timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height);

        // Display an empty tree while loading
        tree.setModel(emptyModel);
        tree.paintImmediately(0, 0, tree.getSize().width, tree.getSize().height);

        startTime = System.currentTimeMillis();

        // Choose the loading method
        if (onlineLoad.isSelected()) {
            // Usual load via setPage
            pane.setPage(url);
            loadedType.setText(pane.getContentType());
        } else {
            pane.setContentType("text/html");
            loadedType.setText(pane.getContentType());
            if (loader == null) {
                loader = new HTMLDocumentLoader();
            }
            HTMLDocument doc = loader.loadDocument(url);
            loadComplete();
            pane.setDocument(doc);
            displayLoadTime();
            populateCombo(findLinks(doc, null));
            TreeNode node = buildHeadingTree(doc);
            tree.setModel(new DefaultTreeModel(node));
            enableInput();
            loadingPage = false;
        }
    } catch (Exception e) {
        System.out.println(e);
        JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", page.toString() },
                "File Open Error", JOptionPane.ERROR_MESSAGE);
        loadingState.setText("Failed");
        enableInput();
        loadingPage = false;
    }
}

From source file:edu.harvard.mcz.imagecapture.data.UnitTrayLabelTableModel.java

private void saveRow(int rowIndex) {
    UnitTrayLabelLifeCycle uls = new UnitTrayLabelLifeCycle();
    try {/*  w  ww .jav a  2 s .c  om*/
        uls.attachDirty(((UnitTrayLabel) labels.get(rowIndex)));
    } catch (SaveFailedException e) {
        log.error(e);
        JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(),
                "Save failed for a unit tray label." + "\n" + e.getMessage(), "Save Failed",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:edu.gmu.cs.sim.util.media.chart.ChartGenerator.java

/** Starts a Quicktime movie on the given ChartGenerator.  The size of the movie frame will be the size of
 the chart at the time this method is called.  This method ought to be called from the main event loop.
 Most of the default movie formats provided will result in a gigantic movie, which you can
 re-encode using something smarter (like the Animation or Sorenson codecs) to put to a reasonable size.
 On the Mac, Quicktime Pro will do this quite elegantly. */
public void startMovie() {
    // can't start a movie if we're in an applet
    if (SimApplet.isApplet()) {
        Object[] options = { "Oops" };
        JOptionPane.showOptionDialog(this, "You cannot create movies from an applet.",
                "MASON Applet Restriction", JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE, null, options,
                options[0]);/*  www  . j a v a  2  s . com*/
        return;
    }

    if (movieMaker != null) {
        return; // already running
    }
    movieMaker = new MovieMaker(getFrame());

    if (!movieMaker.start(getBufferedImage())) {
        movieMaker = null; // failed
    } else {
        movieButton.setText("Stop Movie");

        // emit an image
        update(FORCE_KEY, true);
    }
}

From source file:com.intuit.tank.proxy.ProxyApp.java

/**
 * /* w w w.jav a2 s .  co  m*/
 */
private void openRecording() {
    if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        fileChooser.getSelectedFile();
        try {
            List<Transaction> transactions = new WebConversationJaxbParseXML()
                    .parse(new FileReader(fileChooser.getSelectedFile()));
            model.setTransactions(transactions);
            saveAction.setEnabled(false);
            filterAction.setEnabled(true);
            currentFile = fileChooser.getSelectedFile();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Error opening recording: " + e, "Error",
                    JOptionPane.ERROR_MESSAGE);
        }
    }

}

From source file:com.t3.client.TabletopTool.java

/**
 * Displays the messages provided as <code>messages</code> by calling
 * {@link #showMessage(List<Object>, String, int, Object...)} and passing
 * <code>"msg.title.messageDialogFeedback"</code> and
 * <code>JOptionPane.ERROR_MESSAGE</code> as parameters.
 * /* w  w  w.jav  a2 s . c  o m*/
 * @param messages
 *            the strings to put in the body of the
 *            dialog; no properties file lookup is performed!
 */
public static void showFeedback(List<String> messages) {
    showMessage(messages, "msg.title.messageDialogFeedback", JOptionPane.ERROR_MESSAGE);
}