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:kindleclippings.quizlet.QuizletSync.java

public static Preferences getPrefs()
        throws IOException, URISyntaxException, InterruptedException, JSONException, BackingStoreException {
    Preferences prefs = Preferences.userNodeForPackage(QuizletSync.class);

    String token = prefs.get("access_token", null);
    if (token == null) {
        JSONObject o = GetAccessToken.oauthDance();
        if (o == null) {
            JOptionPane.showMessageDialog(null, "Failed authorization to access Quizlet", "QuizletSync",
                    JOptionPane.ERROR_MESSAGE);
            System.exit(0);// www .  j av a 2  s .c o m
        }
        prefs.put("access_token", o.getString("access_token"));
        prefs.put("user_id", o.getString("user_id"));
        prefs.flush();
    }

    return prefs;
}

From source file:fxts.stations.transport.tradingapi.processors.ExecutionReportProcessor.java

private boolean doReject(ExecutionReport aExeRpt) {
    if (isDisconnect(aExeRpt)) {
        JOptionPane.showMessageDialog(TradeApp.getInst().getMainFrame(), aExeRpt.getFXCMErrorDetails(),
                "Problem with your order..please reconnect.", JOptionPane.ERROR_MESSAGE);
        TradingServerSession.getInstance().logout();
    } else {/*from  w ww. j av  a 2s. co  m*/
        if (aExeRpt.getFXCMOrdStatus() != FXCMOrdStatusFactory.REQUOTED) {
            final String fxcmErrorDetails = aExeRpt.getFXCMErrorDetails();
            mLogger.debug("fxcmErrorDetails = " + fxcmErrorDetails);
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    Message m = new Message(new Date(), "FXCM", "Problem with your order..",
                            OraCodeFactory.toMessage(fxcmErrorDetails));
                    MessageDialog dialog = new MessageDialog(TradeApp.getInst().getMainFrame());
                    Liaison.getInstance().getTradeDesk().addMessage(m);
                    dialog.setMessage(m);
                    dialog.showModal();
                }
            });
            Liaison.getInstance().getTradeDesk().removeOrder(aExeRpt.getOrderID());
        }
    }
    return false;
}

From source file:cpsControllers.ConversionController.java

/**
 * Stosunek sygna - szum (SNR, ang. <i>Signal to Noise Ratio</i>)
 *     //  www  . jav a  2  s  . c  o m
 * @param punktyY
* @return
 */
public double obl_SNR(ArrayList<Double> punktyY, ArrayList<Double> _doPorownania) {
    double wynik = 0;
    try {
        if (!punktyY.isEmpty() && !_doPorownania.isEmpty()) {
            double licznik = 0, mianownik = 0;
            for (int i = 0; i < _doPorownania.size(); i++) {
                licznik = licznik + (punktyY.get(i) * punktyY.get(i));
            }
            for (int i = 0; i < _doPorownania.size(); i++) {
                mianownik = mianownik
                        + (punktyY.get(i) - _doPorownania.get(i)) * (punktyY.get(i) - _doPorownania.get(i));
            }
            wynik = licznik / mianownik;
            wynik = 10.0D * Math.log10(wynik);
        } else {
            if (punktyY.isEmpty()) {
                JOptionPane.showMessageDialog(null, "Brak sygnau.", "Bd", JOptionPane.ERROR_MESSAGE);
            } else if (_doPorownania.isEmpty()) {
                JOptionPane.showMessageDialog(null, "Brak konwersji sygnau.", "Bd",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    } catch (Exception exc_MSE) {
        //            JOptionPane.showMessageDialog(null, "Nie mona obliczy:\n" + exc_MSE.getMessage(),
        //                    "Bd", JOptionPane.ERROR_MESSAGE);
        wynik = -1;
    }

    System.out.println("SNR = " + wynik);
    return wynik;
}

From source file:net.sourceforge.happybank.main.BankMain.java

private void onViewAccount() {

    List<Customer> customers = null;
    try {//from w  w w .  j  a  v  a2 s  .com
        customers = bank.getCustomers();
    } catch (BankException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    Account account = null;
    StringBuffer currentCustomerId = new StringBuffer();

    // if we have nothing to delete
    if (accountEntries.getSelectedRowCount() < 1) {
        return;
    }

    // get the selected customer
    int rowSelected = accountEntries.getSelectedRow();
    try {
        currentCustomerId.append(accountEntries.getValueAt(rowSelected, 5).toString());
        account = bank.getAccount(accountEntries.getValueAt(rowSelected, 0).toString());
    } catch (AccountDoesNotExistException e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "Unable to read account " + account.getId(), "Account Error",
                JOptionPane.ERROR_MESSAGE);
    } catch (BankException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    AccountViewer ae = new AccountViewer(frame, true, account, customers, currentCustomerId, true);
    ae.pack();
    ae.setVisible(true);

}

From source file:ee.ioc.cs.vsle.vclass.VPackage.java

private boolean createPainterPrototypes() {
    boolean success = true;
    /* TODO Will be replaced by more general daemon stuff */
    PackageClassLoader pcl = null;/*from   www  . j  a  v  a2  s  . com*/

    for (PackageClass pclass : getClasses()) {
        if (pclass.getPainterName() == null)
            continue;

        try {
            if (pcl == null) {
                pcl = getPackageClassLoader();
            }
            Class<?> painterClass = pcl.loadClass(pclass.getPainterName());
            pclass.setPainterPrototype((ClassPainter) painterClass.newInstance());
        } catch (CompileException e) {
            success = false;
            logger.error(null, e); // print compiler generated message
        } catch (Exception e) {
            success = false;
            logger.error(null, e);
        } finally {
            if (pcl != null && pcl.hasErrors()) {
                pcl.clearProblems();
            }
        }
    }

    if (!success) {
        JOptionPane.showMessageDialog(Editor.getInstance(),
                "One or more errors occured. See the error log for details.", "Error",
                JOptionPane.ERROR_MESSAGE);
    }

    return success;
}

From source file:EditorPaneExample10A.java

public EditorPaneExample10A() {
    super("JEditorPane Example 10 - using getIterator");

    pane = new JEditorPane();
    pane.setEditable(false); // Read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;//ww  w  . j  a  v a 2 s .  c o m
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            try {
                // Check if the new page and the old
                // page are the same.
                URL url;
                if (selection instanceof URL) {
                    url = (URL) selection;
                } else {
                    url = new URL((String) selection);
                }

                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(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // 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);

                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));
                    enableInput();
                }
            } catch (Exception e) {
                System.out.println(e);
                JOptionPane.showMessageDialog(pane,
                        new String[] { "Unable to open file", selection.toString() }, "File Open Error",
                        JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                enableInput();
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                enableInput();
            }
        }
    });
}

From source file:net.sf.jabref.importer.fetcher.INSPIREFetcher.java

/**
 * Import an entry from an OAI2 archive. The BibEntry provided has to have the field OAI2_IDENTIFIER_FIELD set to
 * the search string.//from   w ww .j a v a2s.  com
 *
 * @param key The OAI2 key to fetch from ArXiv.
 * @return The imported BibEntry or null if none.
 */
private BibDatabase importInspireEntries(String key, OutputPrinter frame) {
    String url = constructUrl(key);
    try {
        HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
        conn.setRequestProperty("User-Agent", "JabRef");
        InputStream inputStream = conn.getInputStream();

        try (INSPIREBibtexFilterReader reader = new INSPIREBibtexFilterReader(
                new InputStreamReader(inputStream, Charset.forName("UTF-8")))) {

            ParserResult pr = BibtexParser.parse(reader);

            return pr.getDatabase();
        }
    } catch (RuntimeException | IOException e) {
        frame.showMessage(Localization.lang("An Exception occurred while accessing '%0'", url) + "\n\n" + e,
                getTitle(), JOptionPane.ERROR_MESSAGE);
    }
    return null;
}

From source file:edu.virginia.speclab.juxta.author.view.export.WebServiceExportDialog.java

private void authenticateUser() {
    try {/*from  www .j  a v  a  2  s  .  c o m*/
        // validate login credentials and get workspace
        if (this.wsClient.authenticate(this.juxtaFrame.getWebUserEmail(),
                // if this somehow fails, blow away the saved credentials
                // show a warning and bail. Next time export is cliced
                // the user will land on the login page.
                this.juxtaFrame.getWebUserPassword()) == false) {
            this.juxtaFrame.setWebUserEmail("");
            this.juxtaFrame.setWebUserPassword("");
            throw new IOException("Invalid email and/or password");
        }
    } catch (IOException e) {
        JOptionPane.showMessageDialog(this.juxtaFrame,
                "An error occurred during login,\nplease try again later.\n\nError: " + e.getMessage(),
                "System Error", JOptionPane.ERROR_MESSAGE);
        setVisible(false);
    }
}

From source file:edu.ku.brc.specify.plugins.LocalityGeoRefPlugin.java

/**
 * Dispatches processing command to the provider.
 *///  w w  w.  jav  a 2 s  .  c om
protected void sendToGeoRefTool() {
    if (locality != null) {
        Geography geo = locality.getGeography();
        if (geo == null) {
            if (geoId != null) {
                ValComboBoxFromQuery cbx = parent.getCompById(geoId);
                if (cbx != null) {
                    geo = (Geography) cbx.getValue();
                }
            } else {
                JOptionPane.showMessageDialog(null, "The LatLonUI is missing the 'geoid' parameter", "Error",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }
        }

        if (geo != null) {
            String country = GeoRefRecordSetProcessorBase.getNameForRank(geo, 200);
            String state = GeoRefRecordSetProcessorBase.getNameForRank(geo, 300);
            String county = GeoRefRecordSetProcessorBase.getNameForRank(geo, 400);

            int id = locality.getLocalityId() != null ? locality.getLocalityId() : 1;

            String locName = locality.getLocalityName();
            if (StringUtils.isEmpty(locName)) {
                if (locId != null) {
                    ValTextField txt = parent.getCompById(locId);
                    if (txt != null) {
                        locName = (String) txt.getValue();
                    }
                } else {
                    JOptionPane.showMessageDialog(null, "The LatLonUI is missing the 'locid' parameter",
                            "Error", JOptionPane.ERROR_MESSAGE);
                }
            }
            GeoCoordData geoCoordData = new GeoCoordData(id, country, state, county == null ? "" : county,
                    locName, locality.getErrorPolygon(), locality.getErrorEstimate());

            List<GeoCoordDataIFace> items = new Vector<GeoCoordDataIFace>();
            items.add(geoCoordData);

            CommandAction command = new CommandAction(PluginsTask.PLUGINS, PluginsTask.EXPORT_LIST);
            command.setData(items);
            command.setProperty("tool",
                    doGeoLocate ? GeoLocateRecordSetProcessor.class : BGMRecordSetProcessor.class);
            command.setProperty("listener", this);

            JStatusBar statusBar = UIRegistry.getStatusBar();
            statusBar.setText(
                    UIRegistry.getResourceString(doGeoLocate ? "GEOLOC_PROCESSING" : "BGM_PROCESSING"));
            CommandDispatcher.dispatch(command);

        } else {
            UIRegistry.displayErrorDlgLocalized(doGeoLocate ? "GEOLOC_REQUIRED" : "BGM_GEO_REQUIRED");
        }
    }
}

From source file:org.vrjuggler.perfmon.PerformanceMonitorGUI.java

/**
 * Implements the Tweek CommunicationListener interface needed for being
 * informed of connections and disconnections with remote CORBA servers.
 *//*from  w  ww  . j a  va2  s  .  c  o  m*/
public void connectionOpened(CommunicationEvent e) {
    System.out.println("PerfMon Connection Opened.");
    // The first thing to do is get the CORBA service object from the
    // event.  We need this so we know to whom we are are connecting.  Once
    // we have the CORBA service, we get its Subject Manager since that's
    // what contains the actual subjects we need.
    CorbaService corba_service = e.getCorbaService();
    SubjectManager mgr = corba_service.getSubjectManager();

    Subject subject = mgr.getSubject("CorbaPerfPlugin");

    // Try to narrow the Subjet object to a SliderSubject object.  If this
    // fails, it throws a CORBA BAD_PARAM exception.  In that case, we open
    // a dialog box saying that the narrowing failed.
    try {
        mPerformanceMonitorSubject = PerformanceMonitorSubjectHelper.narrow(subject);
    } catch (BAD_PARAM narrow_ex) {

        System.out.println("[DBG] Caught BAD_PARAM setting mPerformanceMonitorSubject to Null");
        mPerformanceMonitorSubject = null;
        JOptionPane.showMessageDialog(null, "Failed to narrow subject to CorbaPerfPlugin",
                "CorbaPerfPlugin Narrow Error", JOptionPane.ERROR_MESSAGE);
    }
    //if (CommunicationEvent.CONNECT == e.getType())
    // Ensure that slide_subject is a valid object just to be safe.
    if (mPerformanceMonitorSubject != null) {
        // First, we need a Java object that implements the Observer.  That
        // object must be registered with the Java CORBA service.
        mPerfMonObserver = new PerformanceMonitorObserverImpl(mPerformanceMonitorSubject);
        //mManipulationPanel.setObserver (mObserver);

        corba_service.registerObject(mPerfMonObserver, "PerformanceMonitorObserver");

        // Now that the observer is registered, we can attach it to the
        // subject.  The subject needs to know who its observers are so
        // that it can notify them of updates.
        mPerformanceMonitorSubject.attach(mPerfMonObserver._this());

        // Now that we have the Subject narrowed, start the thread
        // to poll data from the c++ side
        mUpdaterThread = new Thread(new Updater(mDataset, mSpinnerModel, mPerfMonObserver));

        ///Start the updater thread.
        mUpdaterThread.start();
    }
}