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:com.emr.utilities.DatabaseManager.java

/**
 * Save database settings to a properties file
 * @param fileName {@link String} Properties file name
 * @param prefix {@link String} Prefix of the fields (emr|mpi)
 *//*  ww  w.java2 s.co m*/
public void saveSettings(String fileName, String prefix) {
    try {

        output = new FileOutputStream("config/" + fileName);

        // set the properties value
        prop.setProperty(prefix + "_servername", servername);
        prop.setProperty(prefix + "_port", port);
        prop.setProperty(prefix + "_url", url);
        prop.setProperty(prefix + "_dbname", dbName);
        prop.setProperty(prefix + "_dbuser", userName);
        prop.setProperty(prefix + "_dbpassword", password);

        // save properties to project root folder
        prop.store(output, null);
        JOptionPane.showMessageDialog(null, "Connection Settings successfully saved.",
                "Save Connection Settings", JOptionPane.INFORMATION_MESSAGE);
    } catch (IOException io) {
        JOptionPane.showMessageDialog(null, "I/O Error: " + io.getMessage(), "Exception!",
                JOptionPane.ERROR_MESSAGE);
    } finally {
        if (output != null) {
            try {
                output.close();
            } catch (IOException e) {
                //e.printStackTrace();
            }
        }

    }
}

From source file:action.ShowTimeSeriesWithForecastAction.java

/**
* Metoda obslugujaca zdarzenie, odpowiedzialna za inicjalizacje algorytmu genetycznego
*//*w w  w  . j  a  v  a2 s . c  o  m*/
public void actionPerformed(ActionEvent e) {

    try {

        if (window.getSliderSelekcji().getValue() + window.getSliderKrzyzowania().getValue()
                + window.getSliderMutacji().getValue() != 100)
            throw new ParseException(
                    "Please insert correct data for Selection, Crossing and Mutation. The sum of the three has to equal 100%",
                    0);

        TimeSeries timeSeries = window.getCurrentTimeSeries();
        if (timeSeries == null || timeSeries.isEmpty())
            throw new DataLengthException();

        SlidingTimeWindow slidingTimeWindow = new SlidingTimeWindow(
                this.parseToWindowForm(window.getTimeWindowField().getText()));

        if (window.getRdBtnStochastic().isSelected())
            GASettings.getInstance()
                    .setSelectionMethod(SelectionMethod.STOCHASTIC_UNIVERSAL_SAMPLING_SELECTION);

        if (window.getRdbtnArmaForecast().isSelected())
            GASettings.getInstance().setForecastMethod(ForecastMethod.ARMA_FORECAST);

        GASettings.getInstance().setConcurrent(true);

        ApplicationContext context = new AnnotationConfigApplicationContext(ForecastConfig.class);
        AbstractForecast forecast = (AbstractForecast) context.getBean("forecast");

        forecast.initializeGeneticAlgorithm((TimeSeries) timeSeries.clone(),
                (Integer) window.getPopulSizeField().getValue(), slidingTimeWindow,
                (Integer) window.getIterNumberField().getValue(),
                (double) window.getSliderProbOfCross().getValue() / 100,
                (double) window.getSliderProbOfMutat().getValue() / 100,
                (double) window.getSliderSelekcji().getValue() / 100,
                (double) window.getSliderKrzyzowania().getValue() / 100,
                (double) window.getSliderMutacji().getValue() / 100);
        forecast.initializeForecast((Integer) window.getPeriodOfPredField().getValue());

        forecast.addObserver(new GAChartObserver(window.getFitnessChart(),
                window.getTimeSeriesChartWithForecast(), (Integer) window.getPeriodOfPredField().getValue()));
        forecast.addObserver(new GAStatisticObserver(window.getForecast(),
                (Integer) window.getPeriodOfPredField().getValue()));
        forecast.execute();
        window.getTabbedPane().setSelectedIndex(3);

    } catch (CloneNotSupportedException e1) {
        e1.printStackTrace();
    } catch (DataLengthException de) {
        JOptionPane.showMessageDialog(window, "Current data is not set or empty", "Error",
                JOptionPane.ERROR_MESSAGE);
    } catch (ParseException pe) {
        JOptionPane.showMessageDialog(window, pe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    } catch (Exception exc) {
        JOptionPane.showMessageDialog(window, "Wrong data", "Error", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:latexstudio.editor.DbxFileActions.java

/**
 * Shows a .tex files list from user's dropbox and opens the selected one
 *
 * @return List, that contatins user's .tex files from his dropbox; can be
 * empty//from ww w  . j  a  va2 s .  co  m
 */
public void openFromDropbox(DropboxRevisionsTopComponent drtc, RevisionDisplayTopComponent revtc) {
    List<DbxEntryDto> dbxEntries = getDbxTexEntries(DbxUtil.getDbxClient());

    if (!dbxEntries.isEmpty()) {
        JList<DbxEntryDto> list = new JList(dbxEntries.toArray());
        list.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
        int option = JOptionPane.showConfirmDialog(null, list, "Open file from Dropbox",
                JOptionPane.OK_CANCEL_OPTION);

        if (option == JOptionPane.OK_OPTION && !list.isSelectionEmpty()) {
            DbxEntryDto entry = list.getSelectedValue();
            String localPath = ApplicationUtils.getAppDirectory() + File.separator + entry.getName();
            File outputFile = DbxUtil.downloadRemoteFile(entry, localPath);

            revtc.close();

            drtc.updateRevisionsList(entry.getPath());
            drtc.open();
            drtc.requestActive();

            String content = FileService.readFromFile(outputFile.getAbsolutePath());
            etc.setEditorContent(content);
            etc.setCurrentFile(outputFile);
            etc.setDbxState(new DbxState(entry.getPath(), entry.getRevision()));
            etc.setModified(false);
            etc.setPreviewDisplayed(false);
        }
    } else {
        JOptionPane.showMessageDialog(etc, "No .tex files found!", "Error", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:com.bwc.ora.views.LrpDisplayFrame.java

private LrpDisplayFrame() {
    //set up frame and chart
    //configure initial display setting for the panel
    chartPanel = new ChartPanel(null);
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseWheelEnabled(true);
    this.setSize(800, 800);
    add(chartPanel, BorderLayout.CENTER);

    //make it so this jframe can't gain focus
    setFocusableWindowState(false);/*from   w  w w.j  av a 2 s  . c o  m*/

    //add listener to check to see which LRP should be displayed
    lrps.addListSelectionListener((ListSelectionEvent e) -> {
        if (!e.getValueIsAdjusting()) {
            if (lrps.getSelectedIndex() > -1) {
                setChart(lrps.getSelectedValue().getAllSeriesData());
                setVisible(true);
            } else {
                setVisible(false);
            }
        }
    });

    //add listener to check for updates to lrp selection to change lrp
    lrpSettings.addPropertyChangeListener(e -> {
        if (lrps.getSelectedIndex() > -1) {
            if (e.getPropertyName().equals(LrpSettings.PROP_LRP_WIDTH)) {
                Lrp newLrp;
                try {
                    newLrp = new Lrp(Collections.getInstance().getLrpCollection().getSelectedValue().getName(),
                            Collections.getInstance().getLrpCollection().getSelectedValue()
                                    .getLrpCenterXPosition(),
                            Collections.getInstance().getLrpCollection().getSelectedValue()
                                    .getLrpCenterYPosition(),
                            ModelsCollection.getInstance().getLrpSettings().getLrpWidth(),
                            ModelsCollection.getInstance().getLrpSettings().getLrpHeight(),
                            Collections.getInstance().getLrpCollection().getSelectedValue().getType());
                } catch (LRPBoundaryViolationException e1) {
                    JOptionPane.showMessageDialog(null, e1.getMessage() + " Try again.", "LRP generation error",
                            JOptionPane.ERROR_MESSAGE);
                    lrpSettings.setLrpWidth((int) e.getOldValue());
                    return;
                }
                Collections.getInstance().getLrpCollection().setLrp(newLrp,
                        Collections.getInstance().getLrpCollection().getSelectedIndex());
            } else {
                updateSeries(lrps.getSelectedValue().getAllSeriesData());
            }
        }
    });

    //add listener to check for updates to oct settings to change lrp
    octSettings.addPropertyChangeListener(e -> {
        if (lrps.getSelectedIndex() > -1) {
            switch (e.getPropertyName()) {
            case OctSettings.PROP_APPLY_CONTRAST_ADJUSTMENT:
            case OctSettings.PROP_APPLY_NOISE_REDUCTION:
            case OctSettings.PROP_DISPLAY_LOG_OCT:
            case OctSettings.PROP_SHARPEN_KERNEL_RADIUS:
            case OctSettings.PROP_SHARPEN_WEIGHT:
            case OctSettings.PROP_SMOOTHING_FACTOR:
                updateSeries(lrps.getSelectedValue().getAllSeriesData());
            default:
                break;
            }
        }
    });

    //add listener to see if the LRP display needs updating when a selection on oct changes
    lrps.addListDataChangeListener(new ListDataListener() {
        @Override
        public void intervalAdded(ListDataEvent e) {
        }

        @Override
        public void intervalRemoved(ListDataEvent e) {
        }

        @Override
        public void contentsChanged(ListDataEvent e) {
            clearAnnotations();
            updateSeries(lrps.getSelectedValue().getAllSeriesData());
        }
    });

    //add mouse listener for chart to detect when to display labels for
    //peaks in the pop-up menu, also specify what to do when label is clicked
    chartPanel.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseClicked(ChartMouseEvent cme) {
            ChartEntity entity = cme.getEntity();
            if (entity instanceof XYItemEntity && cme.getTrigger().getButton() == MouseEvent.BUTTON1) {

                XYItemEntity item = (XYItemEntity) entity;
                LabelPopupMenu labelMenu = new LabelPopupMenu(chartPanel, item, lrps.getSelectedValue());

                labelMenu.show(chartPanel, cme.getTrigger().getX(), cme.getTrigger().getY());
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
            //do nothing
        }

    });
}

From source file:model.finance_management.Decision_Helper_Model.java

public void getGoal() {

    String sql = "SELECT `Monthly Profit Goal` FROM decision_helper ";
    String sql1 = "SELECT `Annual Profit Goal` FROM decision_helper ";
    String sql2 = "SELECT `Daily Profit Goal` FROM decision_helper  ";

    try {/*from www.  jav  a2  s  .  co  m*/
        pst = con.prepareStatement(sql);
        ResultSet rs = pst.executeQuery();
        if (rs.next()) {
            String RoomReservationMGoal = rs.getString("Monthly Profit Goal");
            Decision_Helper_Frame.txtMonthlyProfitGoal.setText(RoomReservationMGoal);
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e, "Error", JOptionPane.ERROR_MESSAGE);
    }

    try {
        pst = con.prepareStatement(sql1);
        ResultSet rs = pst.executeQuery();
        if (rs.next()) {
            String RoomReservationAGoal = rs.getString("Annual Profit Goal");
            Decision_Helper_Frame.txtAnnualProfitGoal.setText(RoomReservationAGoal);
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e, "Error", JOptionPane.ERROR_MESSAGE);
    }

    try {
        pst = con.prepareStatement(sql2);
        ResultSet rs = pst.executeQuery();
        if (rs.next()) {
            String RoomReservationDGoal = rs.getString("Daily Profit Goal");
            Decision_Helper_Frame.txtDailyProfitGoal.setText(RoomReservationDGoal);
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e, "Error", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:net.aepik.alasca.gui.ldap.SchemaObjectEditorFrame.java

/**
 * Gre les actions de la vue et permet de modifier les donnes.
 * @param e L'action souleve par un lment du panel.
 *//*from ww w.j av  a2s  .  c  o m*/
public void actionPerformed(ActionEvent e) {
    Object o = e.getSource();
    if (o == boutonOk) {
        if (this.checkNoBlankValues()) {
            this.saveValues();
            this.windowClosing(null);
            this.schema.notifyUpdates(true);
        } else {
            JOptionPane.showMessageDialog(this, "Impossible de spcifier des valeurs nulles", "Erreur",
                    JOptionPane.ERROR_MESSAGE);
        }
    } else if (o == boutonAnnuler) {
        this.windowClosing(null);
    }
}

From source file:org.obiba.onyx.jade.instrument.ricelake.RiceLakeWeightInstrumentRunner.java

@Override
public void initialize() {
    if (!externalAppHelper.isSotfwareAlreadyStarted("tanitaInstrumentRunner")) {
        log.info("Refresh serial port list");
        refreshSerialPortList();//w  ww.  java2s.co m
        log.info("Setup serial port");
        setupSerialPort();
    } else {
        JOptionPane.showMessageDialog(null, resourceBundle.getString("Err.Application_lock"),
                resourceBundle.getString("Title.Cannot_start_application"), JOptionPane.ERROR_MESSAGE);
        shutdown = true;
    }
}

From source file:net.sf.profiler4j.console.Console.java

public void error(String message) {
    showMessageDialog(mainFrame, message, "Error", JOptionPane.ERROR_MESSAGE);
}

From source file:ch.descabato.browser.BackupBrowser.java

public static void main2(final String[] args)
        throws InterruptedException, InvocationTargetException, SecurityException, IOException {
    if (args.length > 1)
        throw new IllegalArgumentException(
                "SYNTAX:  java... " + BackupBrowser.class.getName() + " [initialPath]");

    SwingUtilities.invokeAndWait(new Runnable() {

        @Override//w  w w  .j a v a 2  s  . c o m
        public void run() {
            tryLoadSubstanceLookAndFeel();
            final JFrame f = new JFrame("OtrosVfsBrowser demo");
            f.addWindowListener(finishedListener);
            Container contentPane = f.getContentPane();
            contentPane.setLayout(new BorderLayout());
            DataConfiguration dc = null;
            final PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration();
            File favoritesFile = new File("favorites.properties");
            propertiesConfiguration.setFile(favoritesFile);
            if (favoritesFile.exists()) {
                try {
                    propertiesConfiguration.load();
                } catch (ConfigurationException e) {
                    e.printStackTrace();
                }
            }
            dc = new DataConfiguration(propertiesConfiguration);
            propertiesConfiguration.setAutoSave(true);
            final VfsBrowser comp = new VfsBrowser(dc, (args.length > 0) ? args[0] : null);
            comp.setSelectionMode(SelectionMode.FILES_ONLY);
            comp.setMultiSelectionEnabled(true);
            comp.setApproveAction(new AbstractAction(Messages.getMessage("demo.showContentButton")) {
                @Override
                public void actionPerformed(ActionEvent e) {
                    FileObject[] selectedFiles = comp.getSelectedFiles();
                    System.out.println("Selected files count=" + selectedFiles.length);
                    for (FileObject selectedFile : selectedFiles) {
                        try {
                            FileSize fileSize = new FileSize(selectedFile.getContent().getSize());
                            System.out.println(selectedFile.getName().getURI() + ": " + fileSize.toString());
                            Desktop.getDesktop()
                                    .open(new File(new URI(selectedFile.getURL().toExternalForm())));
                            //                byte[] bytes = readBytes(selectedFile.getContent().getInputStream(), 150 * 1024l);
                            //                JScrollPane sp = new JScrollPane(new JTextArea(new String(bytes)));
                            //                JDialog d = new JDialog(f);
                            //                d.setTitle("Content of file: " + selectedFile.getName().getFriendlyURI());
                            //                d.getContentPane().add(sp);
                            //                d.setSize(600, 400);
                            //                d.setVisible(true);
                        } catch (Exception e1) {
                            LOGGER.error("Failed to read file", e1);
                            JOptionPane.showMessageDialog(f,
                                    (e1.getMessage() == null) ? e1.toString() : e1.getMessage(), "Error",
                                    JOptionPane.ERROR_MESSAGE);
                        }
                    }
                }
            });

            comp.setCancelAction(new AbstractAction(Messages.getMessage("general.cancelButtonText")) {
                @Override
                public void actionPerformed(ActionEvent e) {
                    f.dispose();
                    try {
                        propertiesConfiguration.save();
                    } catch (ConfigurationException e1) {
                        e1.printStackTrace();
                    }
                    System.exit(0);
                }
            });
            contentPane.add(comp);

            f.pack();
            f.setVisible(true);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        }
    });
    while (!finished)
        Thread.sleep(100);
}

From source file:net.sf.jabref.external.push.PushToVim.java

@Override
public void operationCompleted(BasePanel panel) {
    if (couldNotConnect) {
        JOptionPane.showMessageDialog(panel.frame(),
                "<HTML>" + Localization.lang("Could not connect to Vim server. Make sure that "
                        + "Vim is running<BR>with correct server name.") + "</HTML>",
                Localization.lang("Error"), JOptionPane.ERROR_MESSAGE);
    } else if (couldNotCall) {
        JOptionPane.showMessageDialog(panel.frame(), Localization.lang("Could not run the 'vim' program."),
                Localization.lang("Error"), JOptionPane.ERROR_MESSAGE);
    } else {/*from   www .  j a  va 2s  . com*/
        super.operationCompleted(panel);
    }
}