Example usage for javax.swing JOptionPane WARNING_MESSAGE

List of usage examples for javax.swing JOptionPane WARNING_MESSAGE

Introduction

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

Prototype

int WARNING_MESSAGE

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

Click Source Link

Document

Used for warning messages.

Usage

From source file:de.dmarcini.submatix.pclogger.gui.MainCommGUI.java

/**
 * Zeigt eine Warnung an Project: SubmatixBTConfigPC Package: de.dmarcini.submatix.pclogger.gui
 * //  www .  j a va  2  s. co  m
 * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 07.01.2012
 * @param msg
 *          Warnmessage
 */
private void showWarnBox(String msg) {
    ImageIcon icon = null;
    try {
        icon = new ImageIcon(MainCommGUI.class.getResource("/de/dmarcini/submatix/pclogger/res/Abort.png"));
        JOptionPane.showMessageDialog(this, msg, LangStrings.getString("MainCommGUI.warnDialog.headline"),
                JOptionPane.WARNING_MESSAGE, icon);
    } catch (NullPointerException ex) {
        statusTextField.setText("ERROR showWarnDialog");
        lg.error("ERROR showWarnDialog <" + ex.getMessage() + "> ABORT!");
        return;
    } catch (MissingResourceException ex) {
        statusTextField.setText("ERROR showWarnDialog");
        lg.error("ERROR showWarnDialog <" + ex.getMessage() + "> ABORT!");
        return;
    } catch (ClassCastException ex) {
        statusTextField.setText("ERROR showWarnDialog");
        lg.error("ERROR showWarnDialog <" + ex.getMessage() + "> ABORT!");
        return;
    }
}

From source file:CSSDFarm.UserInterface.java

private void addSensor() {
    int secondsSeconds = Integer.parseInt(comboIntervalSeconds.getSelectedItem().toString());
    int minutesSeconds = Integer.parseInt(comboIntervalMinutes.getSelectedItem().toString()) * 60;
    int hoursSeconds = Integer.parseInt(comboIntervalHours.getSelectedItem().toString()) * 60 * 60;
    int daysSeconds = Integer.parseInt(comboIntervalDays.getSelectedItem().toString()) * 60 * 60 * 24;
    int interval = secondsSeconds + minutesSeconds + hoursSeconds + daysSeconds;
    int threshold = -1;
    boolean safeToAdd = true;
    if (!txtThreshold.getText().equals("")) {
        try {/*from  ww w  .  ja va  2s .co  m*/
            threshold = Integer.parseInt(txtThreshold.getText());
        } catch (Exception eX) {
            JOptionPane.showMessageDialog(null, eX, "Problem with Threshold", JOptionPane.WARNING_MESSAGE);
            safeToAdd = false;
        }
    }
    if (safeToAdd) {
        boolean upperlimit = checkIsUpperLimit.isSelected();
        server.addSensor(selectedStation.getId(), txtSensorId.getText(),
                (String) comboSensorType.getSelectedItem(), (String) comboSensorUnits.getSelectedItem(),
                interval, threshold, upperlimit);

        panelAddSensor.setVisible(false);
        selectManagerView();
        changeSelectedFieldStation(selectedStation);
        clearSensorScreen();
    }
}

From source file:fi.hoski.remote.ui.Admin.java

private void removeSeries() throws IOException, EntityNotFoundException {
    RaceSeries raceSeries = chooseRace();
    if (raceSeries != null) {
        String event = (String) raceSeries.get(RaceSeries.EVENT);
        if (JOptionPane.showConfirmDialog(panel,
                TextUtil.getText("CONFIRM DELETE")) == JOptionPane.YES_OPTION) {
            int numberOfRaceEntriesFor = dss.getNumberOfRaceEntriesFor(raceSeries);
            if (numberOfRaceEntriesFor > 0) {
                if (JOptionPane.showConfirmDialog(panel, TextUtil.getText("CONFIRM WHOLE RACE DELETE"),
                        TextUtil.getText("FLEET HAS ENTRIES"),
                        JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
                    dss.deleteWithChilds(raceSeries, "RaceFleet");
                }// w w  w  . j  a v a  2s.  com
            } else {
                dss.deleteWithChilds(raceSeries, "RaceFleet");
            }
        }
    }
}

From source file:edu.ku.brc.af.ui.forms.FormViewObj.java

public void doDeleteDataObj(final Object dataObjArg, final DataProviderSessionIFace sessionArg,
        final boolean doDelete) {
    if (doDelete) {
        removeObject(false);//from w  ww.  j a  va 2 s  .  com

    } else {
        DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(dataObjArg.getClass().getName());
        StringBuilder sb = new StringBuilder();
        sb.append(String.format(getResourceString("COULDNT_DELETE_OBJ"), ti.getTitle(),
                ((FormDataObjIFace) dataObjArg).getIdentityTitle()));
        sb.append("\n");
        sb.append(getResourceString("BR_FOUNDINTABLE_LABEL"));
        sb.append("\n");
        for (String s : businessRules.getWarningsAndErrors()) {
            sb.append("  ");
            sb.append(s);
            sb.append("\n");
        }
        JOptionPane.showMessageDialog(UIRegistry.getTopWindow(), sb.toString(),
                getResourceString("COULDNT_DELETE_OBJ_TITLE"), JOptionPane.WARNING_MESSAGE);
    }
}

From source file:mastermind.main.java

private void jButtoncomprobarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtoncomprobarActionPerformed

    if (combinacion.length() == 4 && tiempo.isStarted()) {
        if (combinacion.equals(combinacionsecreta)) {
            JOptionPane.showMessageDialog(this, "Has acertado", "Enhorabuena", INFORMATION_MESSAGE);
            int puntuacion = 0;
            int nivelrepeticion;
            if (!jCheckBoxrepeticion.isSelected()) {
                nivelrepeticion = jComboBoxnivel.getSelectedIndex();
            } else {
                nivelrepeticion = jComboBoxnivel.getSelectedIndex() + 3;
            }/*from ww w .j  a  va 2  s.c o m*/
            switch (nivelrepeticion) {

            case 0:
                puntuacion = ((NIVELMUYFACIL - ((int) tiempo.getTime()) / 100) / intento);
                break;
            case 1:
                puntuacion = (NIVELMUYFACIL - (int) (tiempo.getTime() / 500) / intento);
                break;
            case 2:
                puntuacion = (NIVELMEDIO - (int) (tiempo.getTime() / 1000) / intento);
                break;
            case 3:
                puntuacion = (NIVELDIFICIL / -(int) (tiempo.getTime()) / 1500) / intento;
                break;
            case 4:
                puntuacion = (NIVELMUYDIFICIL - (int) (tiempo.getTime()) / 3000) / intento;
                break;
            case 5:
                puntuacion = (NIVELMEDIO - (int) (tiempo.getTime() / 500) / intento);
                break;
            case 6:
                puntuacion = (NIVELDIFICIL / -(int) (tiempo.getTime()) / 1000) / intento;
                break;
            case 7:
                puntuacion = (NIVELMUYDIFICIL - (int) (tiempo.getTime()) / 1500) / intento;
                break;

            default:

            }
            jFormattedTextFieldpuntuacion.setValue(puntuacion);
            tiempo.stop();
            jToggleButtoncomenzarparar.setSelected(false);
            jToggleButtoncomenzarparar.setText("Comenzar");
            jButtoncomprobar.setEnabled(false);
            jButtonretroceder.setEnabled(true);
            intento++;
            jButtonretroceder.setText("Reiniciar");
            hasacertado = true;

        } else {

            posicion = 0;
            intento++;
        }
        if (jCheckBoxrepeticion.isSelected()) {
            acierto = 0;
            aciertopos = 0;
            for (int i = 0; i < combinacion.length(); i++) {
                System.out.println(combinacion.charAt(i));
                boolean esacierto = false;
                int j = 0;
                do {
                    System.out.println(combinacion.charAt(i) + " " + combinacionsecreta.charAt(j));
                    if (!(combinacion.charAt(i) == combinacionsecreta.charAt(j))) {
                        j++;
                    } else {
                        esacierto = true;
                        if (i == j) {
                            aciertopos++;
                        } else {
                            acierto++;
                        }
                    }
                } while (!esacierto && j < combinacionsecreta.length());
            }
        } else {
            aciertopos = 0;
            acierto = 0;
            String aux = combinacionsecreta;
            System.out.println(combinacion);
            for (int i = 0; i < combinacion.length(); i++) {
                if (combinacion.charAt(i) == combinacionsecreta.charAt(i)) {
                    aciertopos++;
                    String combinacionaux = "";
                    for (int j = 0; j < combinacion.length(); j++) {
                        if (!(j == i)) {
                            combinacionaux += combinacion.charAt(j);

                        } else {

                        }
                    }
                    combinacion = combinacionaux;
                    combinacionaux = "";
                    for (int k = 0; (k < combinacionsecreta.length()); k++) {
                        if (!(k == i)) {
                            combinacionaux += combinacionsecreta.charAt(k);

                        } else {
                            i--;
                        }
                    }
                    combinacionsecreta = combinacionaux;
                }
            }
            int posR = 0, posA = 0, posV = 0, posY = 0, posN = 0, posG = 0;
            for (int i = 0; i < combinacion.length(); i++) {
                int j = 0;
                while (j < combinacionsecreta.length() && i < combinacion.length()) {
                    if (combinacion.charAt(i) == combinacionsecreta.charAt(j)) {
                        System.out.println(combinacion.charAt(i) + " " + combinacionsecreta.charAt(j));

                        switch ((char) combinacionsecreta.charAt(j)) {
                        case 'r':
                            if (j >= posR) {
                                acierto++;
                                posR = j;
                                i++;
                                j = 0;
                            } else {
                                j++;
                            }
                            break;
                        case 'a':
                            if (j >= posA) {
                                acierto++;
                                posA = j;
                                i++;
                                j = 0;
                            } else {
                                j++;
                            }
                            break;
                        case 'v':
                            if (j >= posV) {
                                acierto++;
                                posV = j;
                                i++;
                                j = 0;
                            } else {
                                j++;
                            }
                            break;
                        case 'y':
                            if (j >= posY) {
                                acierto++;
                                posY = j;
                                i++;
                                j = 0;
                            } else {
                                j++;
                            }
                            break;
                        case 'n':
                            if (j >= posN) {
                                acierto++;
                                posN = j;
                                i++;
                                j = 0;
                            } else {
                                j++;
                            }
                            break;
                        case 'g':
                            if (j >= posG) {
                                acierto++;
                                posG = j;
                                i++;
                                j = 0;
                            } else {
                                j++;
                            }
                            break;
                        default:
                        }
                    } else {
                        System.out.println(combinacion.charAt(i) + " " + combinacionsecreta.charAt(j));
                        j++;
                    }
                }
            }
            System.out.println(aciertopos);
            System.out.println(acierto);
            combinacionsecreta = aux;
            combinacion = "";
            System.out.println(combinacionsecreta);
        }
        if (intento >= 0) {
            switch (intento) {
            case 2:
                jTextFieldresultadoAP1.setText(Integer.toString(aciertopos));
                jTextFieldresultadoA1.setText(Integer.toString(acierto));
                break;
            case 3:
                jTextFieldresultadoAP2.setText(Integer.toString(aciertopos));
                jTextFieldresultadoA2.setText(Integer.toString(acierto));
                break;
            case 4:
                jTextFieldresultadoAP3.setText(Integer.toString(aciertopos));
                jTextFieldresultadoA3.setText(Integer.toString(acierto));
                break;
            case 5:
                jTextFieldresultadoAP4.setText(Integer.toString(aciertopos));
                jTextFieldresultadoA4.setText(Integer.toString(acierto));
                break;
            case 6:
                jTextFieldresultadoAP5.setText(Integer.toString(aciertopos));
                jTextFieldresultadoA5.setText(Integer.toString(acierto));
                break;
            case 7:
                jTextFieldresultadoAP6.setText(Integer.toString(aciertopos));
                jTextFieldresultadoA6.setText(Integer.toString(acierto));
                if (!(combinacion.equals(combinacionsecreta)) && !(hasacertado)) {
                    JOptionPane.showMessageDialog(this, "Sin Intentos", "Has Perdido",
                            JOptionPane.WARNING_MESSAGE);
                    tiempo.stop();
                    jToggleButtoncomenzarparar.setSelected(false);
                    jToggleButtoncomenzarparar.setText("Nueva partida");
                    posicion = 0;
                    for (int i = 1; i <= 4; i++) {
                        posicion++;
                        intento = 0;
                        for (int j = 1; j <= 4; j++) {
                            intento++;
                            if (intento == 1) {
                                switch (posicion) {
                                case 1:
                                    jLabel11.setIcon(DEFAULT);
                                    break;
                                case 2:
                                    jLabel12.setIcon(DEFAULT);
                                    break;
                                case 3:
                                    jLabel13.setIcon(DEFAULT);
                                    break;
                                case 4:
                                    jLabel14.setIcon(DEFAULT);
                                    break;
                                }
                            }
                            if (intento == 2) {
                                switch (posicion) {
                                case 1:
                                    jLabel21.setIcon(DEFAULT);
                                    break;
                                case 2:
                                    jLabel22.setIcon(DEFAULT);
                                    break;
                                case 3:
                                    jLabel23.setIcon(DEFAULT);
                                    break;
                                case 4:
                                    jLabel24.setIcon(DEFAULT);
                                    break;
                                }
                            }
                            if (intento == 3) {
                                switch (posicion) {
                                case 1:
                                    jLabel31.setIcon(DEFAULT);
                                    break;
                                case 2:
                                    jLabel32.setIcon(DEFAULT);
                                    break;
                                case 3:
                                    jLabel33.setIcon(DEFAULT);
                                    break;
                                case 4:
                                    jLabel34.setIcon(DEFAULT);
                                    break;
                                }
                            }
                            if (intento == 4) {
                                switch (posicion) {
                                case 1:
                                    jLabel41.setIcon(DEFAULT);
                                    break;
                                case 2:
                                    jLabel42.setIcon(DEFAULT);
                                    break;
                                case 3:
                                    jLabel43.setIcon(DEFAULT);
                                    break;
                                case 4:
                                    jLabel44.setIcon(DEFAULT);
                                    break;
                                }
                            }
                            if (intento == 5) {
                                switch (posicion) {
                                case 1:
                                    jLabel51.setIcon(DEFAULT);
                                    break;
                                case 2:
                                    jLabel52.setIcon(DEFAULT);
                                    break;
                                case 3:
                                    jLabel53.setIcon(DEFAULT);
                                    break;
                                case 4:
                                    jLabel54.setIcon(DEFAULT);
                                    break;
                                }
                            }
                            if (intento == 6) {
                                switch (posicion) {
                                case 1:
                                    jLabel61.setIcon(DEFAULT);
                                    break;
                                case 2:
                                    jLabel62.setIcon(DEFAULT);
                                    break;
                                case 3:
                                    jLabel63.setIcon(DEFAULT);
                                    break;
                                case 4:
                                    jLabel64.setIcon(DEFAULT);
                                    break;
                                }
                            }
                        }
                        intento = 0;
                        posicion = 0;
                    }

                    break;

                }
            }

        }
    }
}

From source file:com.monead.semantic.workbench.SemanticWorkbench.java

/**
 * Configure the proxy settings for executing remote SPARQL queries through a
 * proxy/*from w  ww  .ja va 2 s  .  co m*/
 */
private void configureProxy() {
    final ProxyConfigurationDialog dialog = new ProxyConfigurationDialog(this, proxyServer, proxyPort,
            proxyProtocolHttp, proxyProtocolSocks);

    if (dialog.isAccepted()) {
        if (dialog.getProxyServer().trim().length() > 0) {
            proxyServer = dialog.getProxyServer();
        } else {
            JOptionPane.showMessageDialog(this, "The proxy server cannot be blank", "Proxy Server Required",
                    JOptionPane.ERROR_MESSAGE);
        }
        if (dialog.getProxyPort() != null && dialog.getProxyPort() > 0) {
            proxyPort = dialog.getProxyPort();
        } else {
            JOptionPane
                    .showMessageDialog(this,
                            "The proxy port number must be a number greater than 0\n\nEntered value: "
                                    + dialog.getProxyPort(),
                            "Illegal Proxy Port Number", JOptionPane.ERROR_MESSAGE);
        }
        proxyProtocolHttp = dialog.isProtocolHttp();
        proxyProtocolSocks = dialog.isProtocolSocks();
        if (!proxyProtocolHttp && !proxyProtocolSocks) {
            JOptionPane.showMessageDialog(this,
                    "No protocols were set for proxying.\nEnabling proxying will have no effect.",
                    "Proxy Setting: No Protocols Selected", JOptionPane.WARNING_MESSAGE);
        }

        if (setupProxyEnabled.isSelected()) {
            JOptionPane.showMessageDialog(this, "You must restart the program for these changes to take effect",
                    "Proxy Setting Changed", JOptionPane.INFORMATION_MESSAGE);
        }
    }

    enableControls(true);
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java

public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals(UploadMainPanel.VALIDATE_CONTENT)) {
        validateData(true);//from www . jav  a 2 s  . c  o  m
    } else if (e.getActionCommand().equals(UploadMainPanel.DO_UPLOAD)) {
        if (isUpdateUpload()) {
            if (!isValidUpdateUpload()) {
                UIRegistry.showError("This dataset contains mappings which are not updateable");
                return;
            }
            if (!UIRegistry.displayConfirm("Ready to Update",
                    "This update cannot be undone. Are you sure you want to continue?", "Yes", "No",
                    JOptionPane.WARNING_MESSAGE)) {
                return;
            }
        }
        uploadIt(true);
    } else if (e.getActionCommand().equals(UploadMainPanel.VIEW_UPLOAD)) {
        if (currentOp.equals(Uploader.SUCCESS) || currentOp.equals(Uploader.SUCCESS_PARTIAL)) {
            viewAllObjectsCreatedByUpload();
        }
    } else if (e.getActionCommand().equals(UploadMainPanel.VIEW_SETTINGS)) {
        showSettings();
        if (currentOp.equals(Uploader.READY_TO_UPLOAD) && !resolver.isResolved()) {
            setCurrentOp(Uploader.USER_INPUT);
        } else if (currentOp.equals(Uploader.USER_INPUT) && resolver.isResolved()) {
            setCurrentOp(Uploader.READY_TO_UPLOAD);
        }
    } else if (e.getActionCommand().equals(UploadMainPanel.CLOSE_UI)) {
        if (aboutToShutdown(null)) {
            closeMainForm(true);
        }
    } else if (e.getActionCommand().equals(UploadMainPanel.UNDO_UPLOAD)) {
        if (UIRegistry.displayConfirm(getResourceString("WB_UPLOAD_FORM_TITLE"),
                getResourceString("WB_UNDO_UPLOAD_MSG"), getResourceString("OK"), getResourceString("CANCEL"),
                JOptionPane.QUESTION_MESSAGE)) {
            undoUpload(true, false, true);
        }
    } else if (e.getActionCommand().equals(UploadMainPanel.TBL_DBL_CLICK)) {
        mainPanel.getViewUploadBtn().setEnabled(canViewUpload(currentOp));
        if (currentOp.equals(Uploader.SUCCESS) || currentOp.equals(Uploader.SUCCESS_PARTIAL)) {
            viewAllObjectsCreatedByUpload();
        }
    } else if (e.getActionCommand().equals(UploadMainPanel.TBL_CLICK)) {
        mainPanel.getViewUploadBtn().setEnabled(canViewUpload(currentOp));
    } else if (e.getActionCommand().equals(UploadMainPanel.MSG_CLICK)) {
        goToMsgWBCell((Component) e.getSource(), false);
    } else if (e.getActionCommand().equals(UploadMainPanel.PRINT_INVALID)) {
        printInvalidValReport();
    } else if (e.getActionCommand().equals(UploadMainPanel.CANCEL_OPERATION)) {
        if (currentTask != null && currentTask.isCancellable()) {
            cancelTask(currentTask);
        } else {
            log.info("ignoring action: " + e.getActionCommand());
        }
    } else
        log.error("Unrecognized action: " + e.getActionCommand());
}

From source file:com.monead.semantic.workbench.SemanticWorkbench.java

/**
 * Startup the SPARQL server//from w ww  . j a v a2s . c o m
 */
private void startSparqlServer() {
    if (!SparqlServer.getInstance().isActive()) {
        if (ontModel != null) {
            publishModelToTheSparqlServer();
            SparqlServer.getInstance().addObserver(this);

            try {
                SparqlServer.getInstance().start();
            } catch (Throwable throwable) {
                LOGGER.error("Unable to start the SPARQL server", throwable);
                SparqlServer.getInstance().deleteObserver(this);
                JOptionPane.showMessageDialog(this,
                        "Unable to start the SPARQL server\n" + throwable.getMessage(),
                        "Cannot Start the SPARQL Server", JOptionPane.ERROR_MESSAGE);
            }

            if (SparqlServer.getInstance().isActive()) {
                if (SparqlServer.getInstance().areRemoteUpdatesPermitted()) {
                    sparqlServerInfo.setBorder(
                            BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.red.darker()),
                                    "SPARQL Server Status (Updates Allowed)",
                                    TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
                                    BorderFactory.createTitledBorder("").getTitleFont(), Color.red.darker()));

                }
                sparqlServerInfo.setForeground(Color.blue.darker());
                updateSparqlServerInfo();
                setStatus("SPARQL server started on port " + SparqlServer.getInstance().getListenerPort()
                        + (SparqlServer.getInstance().areRemoteUpdatesPermitted() ? " (Remote Updates Enabled)"
                                : ""));
            }
        } else {
            JOptionPane.showMessageDialog(this, "You must create a model before starting the SPARQL server",
                    "Cannot Start SPARQL Server", JOptionPane.WARNING_MESSAGE);
        }
    } else {
        setStatus("SPARQL server is already running");
    }

    enableControls(true);
}

From source file:de.bfs.radon.omsimulation.gui.OMPanelSimulation.java

/**
 * Initialises the interface of the simulation panel.
 *//* w ww .j ava 2 s. c  om*/
protected void initialize() {
    setLayout(null);

    btnStart = new JButton("Start");
    btnStart.addActionListener(this);
    btnStart.setBounds(616, 326, 124, 23);
    btnStart.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(btnStart);

    progressBarSimulation = new JProgressBar();
    progressBarSimulation.setBounds(10, 475, 730, 23);
    progressBarSimulation.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    progressBarSimulation.setVisible(false);
    add(progressBarSimulation);

    lblSelectOmbfile = new JLabel("Open OMB-File");
    lblSelectOmbfile.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    lblSelectOmbfile.setBounds(10, 36, 132, 14);
    add(lblSelectOmbfile);

    lblOmsFile = new JLabel("Save OMS-File");
    lblOmsFile.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    lblOmsFile.setBounds(174, 272, 120, 14);
    add(lblOmsFile);

    txtOmsFile = new JTextField();
    txtOmsFile.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent arg0) {
            setOmsFile(txtOmsFile.getText());
        }
    });
    txtOmsFile.setBounds(304, 269, 302, 20);
    txtOmsFile.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(txtOmsFile);
    txtOmsFile.setColumns(10);

    btnBrowseOms = new JButton("Browse");
    btnBrowseOms.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.oms", "oms"));
            fileDialog.showSaveDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String oms;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("oms")) {
                    oms = "";
                } else {
                    oms = ".oms";
                }
                txtOmsFile.setText(file.getAbsolutePath() + oms);
                setOmsFile(file.getAbsolutePath() + oms);
            }
        }
    });
    btnBrowseOms.setBounds(616, 268, 124, 23);
    btnBrowseOms.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(btnBrowseOms);

    lblWarning = new JLabel("This could take a while, grab a coffee!");
    lblWarning.setBounds(421, 94, 319, 15);
    lblWarning.setForeground(new Color(255, 0, 0, 255));
    lblWarning.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(lblWarning);

    lblSelectProject = new JLabel("Select Project");
    lblSelectProject.setBounds(10, 65, 132, 14);
    lblSelectProject.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(lblSelectProject);

    lblSimulationType = new JLabel("Simulation Type");
    lblSimulationType.setBounds(10, 94, 132, 14);
    lblSimulationType.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(lblSimulationType);

    lblCampaigns = new JLabel("campaigns");
    lblCampaigns.setBounds(421, 122, 185, 14);
    lblCampaigns.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(lblCampaigns);

    lblRatio = new JLabel("Ratio");
    lblRatio.setBounds(174, 152, 44, 14);
    lblRatio.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(lblRatio);

    lblPercent = new JLabel("%");
    lblPercent.setBounds(246, 302, 360, 14);
    lblPercent.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(lblPercent);

    spnrRandomCampaigns = new JSpinner();
    spnrRandomCampaigns.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            setRandomCampaigns((Integer) spnrRandomCampaigns.getValue());
        }
    });
    spnrRandomCampaigns.setModel(new SpinnerNumberModel(10000, 10, 100000, 1));
    spnrRandomCampaigns.setBounds(304, 119, 107, 22);
    spnrRandomCampaigns.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(spnrRandomCampaigns);

    spnrRatio3 = new JSpinner();
    spnrRatio3.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            if (chckbxRatio3.isSelected()) {
                setRatio3((Integer) spnrRatio3.getValue());
            } else {
                setRatio3(0);
                spnrRatio3.setEnabled(false);
            }
        }
    });
    spnrRatio3.setModel(new SpinnerNumberModel(2, 0, 10000, 1));
    spnrRatio3.setBounds(330, 149, 81, 22);
    spnrRatio3.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(spnrRatio3);

    spnrRatio4 = new JSpinner();
    spnrRatio4.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            if (chckbxRatio4.isSelected()) {
                setRatio4((Integer) spnrRatio4.getValue());
            } else {
                setRatio4(0);
                spnrRatio4.setEnabled(false);
            }
        }
    });
    spnrRatio4.setModel(new SpinnerNumberModel(5, 0, 10000, 1));
    spnrRatio4.setBounds(330, 179, 81, 22);
    spnrRatio4.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(spnrRatio4);

    spnrRatio5 = new JSpinner();
    spnrRatio5.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            if (chckbxRatio5.isSelected()) {
                setRatio5((Integer) spnrRatio5.getValue());
            } else {
                setRatio5(0);
                spnrRatio5.setEnabled(false);
            }
        }
    });
    spnrRatio5.setModel(new SpinnerNumberModel(20, 0, 10000, 1));
    spnrRatio5.setBounds(330, 209, 81, 22);
    spnrRatio5.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(spnrRatio5);

    spnrRatio6 = new JSpinner();
    spnrRatio6.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            if (chckbxRatio6.isSelected()) {
                setRatio6((Integer) spnrRatio6.getValue());
            } else {
                setRatio6(0);
                spnrRatio6.setEnabled(false);
            }
        }
    });
    spnrRatio6.setModel(new SpinnerNumberModel(73, 0, 10000, 1));
    spnrRatio6.setBounds(330, 239, 81, 22);
    spnrRatio6.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(spnrRatio6);

    spnrRandomNoise = new JSpinner();
    spnrRandomNoise.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            if (chckbxRandomNoise.isSelected()) {
                setRandomNoise((Integer) spnrRandomNoise.getValue());
            } else {
                setRandomNoise(0);
                spnrRandomNoise.setEnabled(false);
            }
        }
    });
    spnrRandomNoise.setModel(new SpinnerNumberModel(5, 0, 20, 1));
    spnrRandomNoise.setBounds(153, 299, 83, 22);
    spnrRandomNoise.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(spnrRandomNoise);

    chckbxRatio3 = new JCheckBox("3 of 6");
    chckbxRatio3.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (chckbxRatio3.isSelected()) {
                if (rdbtnRandom.isSelected()) {
                    spnrRatio3.setEnabled(true);
                }
            } else {
                setRatio3(0);
                spnrRatio3.setEnabled(false);
            }
        }
    });
    chckbxRatio3.setBounds(237, 149, 80, 23);
    chckbxRatio3.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(chckbxRatio3);

    chckbxRatio4 = new JCheckBox("4 of 6");
    chckbxRatio4.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (chckbxRatio4.isSelected()) {
                if (rdbtnRandom.isSelected()) {
                    spnrRatio4.setEnabled(true);
                }
            } else {
                setRatio4(0);
                spnrRatio4.setEnabled(false);
            }
        }
    });
    chckbxRatio4.setBounds(237, 179, 80, 23);
    chckbxRatio4.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(chckbxRatio4);

    chckbxRatio5 = new JCheckBox("5 of 6");
    chckbxRatio5.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (chckbxRatio5.isSelected()) {
                if (rdbtnRandom.isSelected()) {
                    spnrRatio5.setEnabled(true);
                }
            } else {
                setRatio5(0);
                spnrRatio5.setEnabled(false);
            }
        }
    });
    chckbxRatio5.setBounds(237, 209, 80, 23);
    chckbxRatio5.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(chckbxRatio5);

    chckbxRatio6 = new JCheckBox("6 of 6");
    chckbxRatio6.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (chckbxRatio6.isSelected()) {
                if (rdbtnRandom.isSelected()) {
                    spnrRatio6.setEnabled(true);
                }
            } else {
                setRatio6(0);
                spnrRatio6.setEnabled(false);
            }
        }
    });
    chckbxRatio6.setBounds(237, 239, 80, 23);
    chckbxRatio6.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(chckbxRatio6);

    chckbxRandomNoise = new JCheckBox("Random noise");
    chckbxRandomNoise.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (chckbxRandomNoise.isSelected()) {
                if (chckbxRandomNoise.isEnabled()) {
                    spnrRandomNoise.setEnabled(true);
                }
            } else {
                setRandomNoise(0);
                spnrRandomNoise.setEnabled(false);
            }
        }
    });
    chckbxRandomNoise.setBounds(10, 299, 137, 23);
    chckbxRandomNoise.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(chckbxRandomNoise);

    btnRefresh = new JButton("Load");
    btnRefresh.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (txtOmbFile.getText() != null && !txtOmbFile.getText().equals("")
                    && !txtOmbFile.getText().equals(" ")) {
                txtOmbFile.setBackground(Color.WHITE);
                String ombPath = txtOmbFile.getText();
                String omb;
                String[] tmpFileName = ombPath.split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("omb")) {
                    omb = "";
                } else {
                    omb = ".omb";
                }
                txtOmbFile.setText(ombPath + omb);
                setOmbFile(ombPath + omb);
                File ombFile = new File(ombPath + omb);
                if (ombFile.exists()) {
                    txtOmbFile.setBackground(Color.WHITE);
                    btnRefresh.setEnabled(false);
                    comboBoxSelectProject.setEnabled(false);
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    progressBarSimulation.setVisible(true);
                    progressBarSimulation.setStringPainted(true);
                    progressBarSimulation.setIndeterminate(true);
                    refreshTask = new Refresh();
                    refreshTask.execute();
                } else {
                    txtOmbFile.setBackground(new Color(255, 222, 222, 128));
                    JOptionPane.showMessageDialog(null, "OMB-file not found, please check the file path!",
                            "Error", JOptionPane.ERROR_MESSAGE);
                }
            } else {
                txtOmbFile.setBackground(new Color(255, 222, 222, 128));
                JOptionPane.showMessageDialog(null, "Please select an OMB-file!", "Warning",
                        JOptionPane.WARNING_MESSAGE);
            }
        }
    });
    btnRefresh.setBounds(616, 61, 124, 23);
    btnRefresh.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(btnRefresh);

    lblHelp = new JLabel(
            "Select an OMB-Object file to run simulations. Limited random simulations can be saved as OMS-Simulation files used for analysis.");
    lblHelp.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    lblHelp.setForeground(Color.GRAY);
    lblHelp.setBounds(10, 10, 730, 14);
    add(lblHelp);

    txtOmbFile = new JTextField();
    txtOmbFile.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    txtOmbFile.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent arg0) {
            setOmbFile(txtOmbFile.getText());
        }
    });
    txtOmbFile.setBounds(152, 33, 454, 20);
    add(txtOmbFile);
    txtOmbFile.setColumns(10);

    btnBrowseOmb = new JButton("Browse");
    btnBrowseOmb.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    btnBrowseOmb.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.omb", "omb"));
            fileDialog.showOpenDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String omb;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("omb")) {
                    omb = "";
                } else {
                    omb = ".omb";
                }
                txtOmbFile.setText(file.getAbsolutePath() + omb);
                setOmbFile(file.getAbsolutePath() + omb);
            }
        }
    });
    btnBrowseOmb.setBounds(616, 32, 124, 23);
    add(btnBrowseOmb);

    rdbtnSystematic = new JRadioButton("Systematic all campaigns");
    rdbtnSystematic.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            if (rdbtnSystematic.isSelected()) {
                setSystematic(true);
                rdbtnRandom.setSelected(false);
                chckbxRatio6.setEnabled(false);
                chckbxRatio5.setEnabled(false);
                chckbxRatio4.setEnabled(false);
                chckbxRatio3.setEnabled(false);
                spnrRatio6.setEnabled(false);
                spnrRatio5.setEnabled(false);
                spnrRatio4.setEnabled(false);
                spnrRatio3.setEnabled(false);
                spnrRandomCampaigns.setEnabled(false);
                lblRatio.setEnabled(false);
                lblCampaigns.setEnabled(false);
                lblOmsFile.setEnabled(false);
                lblWarning.setVisible(true);
                txtOmsFile.setEnabled(false);
                btnBrowseOms.setEnabled(false);
            } else {
                setSystematic(false);
                rdbtnRandom.setSelected(true);
            }
        }
    });
    rdbtnSystematic.setBounds(152, 90, 259, 23);
    rdbtnSystematic.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(rdbtnSystematic);

    rdbtnRandom = new JRadioButton("Random");
    rdbtnRandom.setSelected(true);
    rdbtnRandom.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (rdbtnRandom.isSelected()) {
                setSystematic(false);
                rdbtnSystematic.setSelected(false);
                chckbxRatio6.setEnabled(true);
                chckbxRatio5.setEnabled(true);
                chckbxRatio4.setEnabled(true);
                chckbxRatio3.setEnabled(true);
                spnrRandomCampaigns.setEnabled(true);
                lblRatio.setEnabled(true);
                lblCampaigns.setEnabled(true);
                lblOmsFile.setEnabled(true);
                lblWarning.setVisible(false);
                txtOmsFile.setEnabled(true);
                btnBrowseOms.setEnabled(true);
            } else {
                setSystematic(true);
                rdbtnSystematic.setSelected(true);
            }
        }
    });
    rdbtnRandom.setBounds(152, 119, 142, 23);
    rdbtnRandom.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(rdbtnRandom);

    comboBoxSelectProject = new JComboBox<OMBuilding>();
    comboBoxSelectProject.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent arg0) {
            boolean b = false;
            if (comboBoxSelectProject.isEnabled()) {
                if (comboBoxSelectProject.getSelectedItem() != null) {
                    b = true;
                    setSelectedObject((OMBuilding) comboBoxSelectProject.getSelectedItem());
                    setProjectName(getSelectedObject().getName());
                } else {
                    b = false;
                }
            } else {
                b = false;
            }
            progressBarSimulation.setEnabled(b);
            btnStart.setEnabled(b);
            chckbxRandomNoise.setEnabled(b);
            rdbtnRandom.setEnabled(b);
            rdbtnSystematic.setEnabled(b);
            lblPercent.setEnabled(b);
            lblRatio.setEnabled(b);
            lblSimulationType.setEnabled(b);
            lblCampaigns.setEnabled(b);
        }
    });
    comboBoxSelectProject.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            boolean b = false;
            if (comboBoxSelectProject.isEnabled()) {
                if (comboBoxSelectProject.getSelectedItem() != null) {
                    b = true;
                    setSelectedObject((OMBuilding) comboBoxSelectProject.getSelectedItem());
                    setProjectName(getSelectedObject().getName());
                } else {
                    b = false;
                }
            } else {
                b = false;
            }
            progressBarSimulation.setEnabled(b);
            btnStart.setEnabled(b);
            chckbxRandomNoise.setEnabled(b);
            rdbtnRandom.setEnabled(b);
            rdbtnSystematic.setEnabled(b);
            lblPercent.setEnabled(b);
            lblRatio.setEnabled(b);
            lblSimulationType.setEnabled(b);
            lblCampaigns.setEnabled(b);
        }
    });
    comboBoxSelectProject.setBounds(152, 61, 454, 22);
    comboBoxSelectProject.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    add(comboBoxSelectProject);

    btnStart.setEnabled(false);
    chckbxRandomNoise.setEnabled(false);
    chckbxRatio6.setEnabled(false);
    chckbxRatio5.setEnabled(false);
    chckbxRatio4.setEnabled(false);
    chckbxRatio3.setEnabled(false);
    spnrRandomNoise.setEnabled(false);
    spnrRatio6.setEnabled(false);
    spnrRatio5.setEnabled(false);
    spnrRatio4.setEnabled(false);
    spnrRatio3.setEnabled(false);
    spnrRandomCampaigns.setEnabled(false);
    rdbtnRandom.setEnabled(false);
    rdbtnSystematic.setEnabled(false);
    lblPercent.setEnabled(false);
    lblRatio.setEnabled(false);
    lblSimulationType.setEnabled(false);
    lblCampaigns.setEnabled(false);
    lblOmsFile.setEnabled(false);
    txtOmsFile.setEnabled(false);
    btnBrowseOms.setEnabled(false);
    spnrRatio6.setValue(73);
    spnrRatio5.setValue(20);
    spnrRatio4.setValue(5);
    spnrRatio3.setValue(2);
    spnrRandomNoise.setValue(5);
    lblWarning.setVisible(false);
}

From source file:stainingestimation.StainingEstimation.java

/**
 * Opens a dialog to let the user chose a table which is then loaded in the staining estimation parameters table view.
 *///w  ww .j  a  va  2  s.c om
private void loadTable() {
    if (previewOriginal != null) {
        String currentDir = manager.getCurrentDir();
        File file = FileChooser.chooseCSVFile(this, currentDir);
        if (file != null) {
            try {
                ((DefaultTableModel) jXTable1.getModel()).setRowCount(0);
                BufferedReader bfr = new BufferedReader(new FileReader(file));
                String line = bfr.readLine();
                int i = 0;
                while (bfr.ready()) {
                    line = bfr.readLine();
                    String[] cells = line.split(";");
                    ((DefaultTableModel) jXTable1.getModel()).setRowCount(++i);
                    for (int j = 0; j < jXTable1.getModel().getColumnCount(); j++) {
                        if (((DefaultTableModel) jXTable1.getModel()).getColumnClass(j) == Double.class) {
                            ((DefaultTableModel) jXTable1.getModel()).setValueAt(Double.parseDouble(cells[j]),
                                    i - 1, j);
                        } else if (((DefaultTableModel) jXTable1.getModel())
                                .getColumnClass(j) == Integer.class) {
                            ((DefaultTableModel) jXTable1.getModel()).setValueAt(Integer.parseInt(cells[j]),
                                    i - 1, j);
                        } else if (((DefaultTableModel) jXTable1.getModel())
                                .getColumnClass(j) == String.class) {
                            ((DefaultTableModel) jXTable1.getModel()).setValueAt(cells[j].replaceAll("\"", ""),
                                    i - 1, j);
                        } else {
                            ((DefaultTableModel) jXTable1.getModel()).setValueAt(cells[j], i - 1, j);
                        }
                    }
                }
                bfr.close();
            } catch (Exception e) {
                Logger.getLogger(StainingEstimation.class.getName()).log(Level.SEVERE, null, e);
            }
        }
    } else {
        JOptionPane.showMessageDialog(this, "Please select first a TMA spot in TMARKER's main window.",
                "Select Image", JOptionPane.WARNING_MESSAGE);
    }
}