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:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java

/**
 * @param op/* ww w. j  a va2s .  com*/
 * 
 * Sets up mainPanel for upload phase for op.
 */
protected void setupUI(final String op) {
    //        SwingUtilities.invokeLater(new Runnable() {
    //           public void run()
    //           {
    if (mainPanel == null) {
        log.error("UI does not exist.");
        return;
    }

    if (op.equals(Uploader.RETRIEVING_UPLOADED_DATA)) {
        //There's really nothing to do in this case anymore
        return;
    }

    int uploadedObjects = getUploadedObjects();

    if (op.equals(Uploader.SUCCESS) || op.equals(Uploader.SUCCESS_PARTIAL)) {
        if (mainPanel.getUploadTbls().getSelectedIndex() == -1) {
            // assuming list is not empty
            mainPanel.getUploadTbls().setSelectedIndex(0);
        }
    }

    if (op.equals(Uploader.SUCCESS) || op.equals(Uploader.SUCCESS_PARTIAL)) {
        if (uploadedObjects > 0 && !isUpdateUpload()) {
            mainPanel.closeBtn.setText(getResourceString("WB_UPLOAD.COMMIT"));
        } else {
            mainPanel.closeBtn.setText(getResourceString("CLOSE"));
        }
    }

    if (op.equals(Uploader.READY_TO_UPLOAD)) {
        mainPanel.closeBtn.setText(getResourceString("CLOSE"));
    }

    if (op.equals(UPLOADING) || op.equals(SUCCESS) || op.equals(Uploader.SUCCESS_PARTIAL)) {
        mainPanel.showUploadTblTbl();
    } else if (uploadedObjects == 0 || op.equals(Uploader.READY_TO_UPLOAD)) {
        mainPanel.showUploadTblList();
    }

    mainPanel.getValidateContentBtn().setEnabled(canValidateContent(op));

    mainPanel.getCancelBtn().setEnabled(canCancel(op));
    if (mainPanel.getCancelBtn().isEnabled()) {
        if (op.equals(UPLOADING)) {
            mainPanel.getCancelBtn().setText(getResourceString("WB_UPLOAD_PAUSE"));
        } else {
            mainPanel.getCancelBtn().setText(getResourceString("WB_UPLOAD_CANCEL"));
        }
    }

    mainPanel.getCancelBtn().setVisible(mainPanel.getCancelBtn().isEnabled());

    mainPanel.getDoUploadBtn().setEnabled(canUpload(op));

    mainPanel.getViewSettingsBtn().setEnabled(canViewSettings(op));

    mainPanel.getViewUploadBtn().setEnabled(canViewUpload(op) && uploadedObjects > 0);
    mainPanel.getViewUploadBtn().setVisible(mainPanel.getViewUploadBtn().isEnabled());

    mainPanel.getUndoBtn().setEnabled(canUndo(op) && uploadedObjects > 0);
    mainPanel.getUndoBtn().setVisible(mainPanel.getUndoBtn().isEnabled());

    mainPanel.getCloseBtn().setEnabled(canClose(op));

    mainPanel.getCurrOpProgress().setVisible(mainPanel.getCancelBtn().isVisible());

    String statText;
    if (previousOp != null && previousOp.equals(UNDOING_UPLOAD) && op.equals(FAILURE)) {
        statText = getResourceString("WB_UPLOAD_UNDO_FAILURE");
    } else {
        statText = getResourceString(op);
    }
    Exception killer = getOpKiller();
    if (op.equals(Uploader.SUCCESS) || op.equals(Uploader.SUCCESS_PARTIAL)) {
        statText += ". " + getUploadedObjects().toString() + " " + getResourceString("WB_UPLOAD_OBJECT_COUNT")
                + ".";
        if (killer != null) {
            logDebug("Hey. Wait a minute. The operation succeeded while dead. Is that not creepy?");
        }
    } else if (op.equals(Uploader.FAILURE) && killer != null) {
        if (StringUtils.isNotEmpty(killer.getLocalizedMessage())) {
            statText += ": " + killer;
        } else {
            statText += ": " + killer.getClass().getName();
        }
    }
    if (dotDotDot(op)) {
        statText += "...";
    }

    mainPanel.clearMsgs(new Class<?>[] { UploadTableInvalidValue.class });
    if (op.equals(USER_INPUT)) {
        mainPanel.addMsg(new UploadTableInvalidValue(statText, null, -1, null));
    } else {
        mainPanel.addMsg(new BaseUploadMessage(statText));
    }

    if (validationIssues != null) {
        for (int m = 0; m < validationIssues.size() && m < MAX_MSG_DISPLAY_COUNT; m++) {
            mainPanel.addMsg(validationIssues.get(m));
        }
        if (validationIssues.size() > MAX_MSG_DISPLAY_COUNT) {
            log.info("Only displaying " + String.valueOf(MAX_MSG_DISPLAY_COUNT) + " of "
                    + String.valueOf(validationIssues.size()) + " validation errors ");
            thirdTime = thirdTime + 1;
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    JOptionPane.showMessageDialog(UIRegistry.getTopWindow(),
                            String.format(getResourceString(WB_TOO_MANY_ERRORS),
                                    String.valueOf(MAX_MSG_DISPLAY_COUNT),
                                    String.valueOf(validationIssues.size())),
                            getResourceString(WB_UPLOAD_FORM_TITLE), JOptionPane.WARNING_MESSAGE, null);
                }
            });
        }
    }
    mainPanel.getPrintBtn().setEnabled(validationIssues != null && validationIssues.size() > 0);
    //           }
    //        });
}

From source file:course_generator.frmMain.java

/**
 * Called when the main form is closing//from w ww.  j  a  v a  2  s  . co  m
 * 
 * @param evt
 */
private void formWindowClosing(java.awt.event.WindowEvent evt) {
    if (Track.isModified) {
        Object[] options = { " " + bundle.getString("frmMain.ClosingYes") + " ",
                " " + bundle.getString("frmMain.ClosingNo") + " " };
        int ret = JOptionPane.showOptionDialog(this, bundle.getString("frmMain.ClosingMessage"),
                bundle.getString("frmMain.ClosingTitle"), JOptionPane.YES_NO_OPTION,
                JOptionPane.WARNING_MESSAGE, null, options, options[1]);

        if (ret == JOptionPane.YES_OPTION) {
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            SaveConfig();
        } else {
            setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        }
    } else { // No modification! Bye
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        SaveConfig();
    }
}

From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java

/**
 * @param query/*from ww w  .j a  va 2 s .co m*/
 * @return true if query can be saved
 * 
 * checks that criteria lengths can fit in to the db fields that store them.
 * if un-saveable values exists, user is allowed to cancel save or
 * save with the un-saveable values discarded.
 */
protected boolean checkCriteriaLengths(final SpQuery query) {
    boolean result = true;
    Set<SpQueryField> flds = query.getFields();

    DBTableInfo tblInfo = DBTableIdMgr.getInstance().getInfoByTableName("spqueryfield");
    int maxStartLen = tblInfo.getFieldByColumnName("StartValue").getLength();
    int maxEndLen = tblInfo.getFieldByColumnName("EndValue").getLength();
    Vector<String> badFields = new Vector<String>();
    if (flds != null) {
        for (SpQueryField fld : flds) {
            Integer startLen = fld.getStartValue() == null ? 0 : fld.getStartValue().length();
            Integer endLen = fld.getEndValue() == null ? 0 : fld.getEndValue().length();
            if (startLen > maxStartLen || endLen > maxEndLen) {
                badFields.add(fld.getColumnAliasTitle());
            }
        }
        if (badFields.size() > 0) {
            String fldList = "";
            for (int f = 0; f < 5 && f < badFields.size(); f++) {
                if (f > 0)
                    fldList += ", ";
                fldList += badFields.get(f);
            }
            if (badFields.size() > 5)
                fldList += ", ... ";
            result = UIRegistry
                    .displayConfirm(UIRegistry.getResourceString("QueryTask.CRITERIA_TOO_LONG_TITLE"),
                            String.format(UIRegistry.getResourceString("QueryTask.CRITERIA_TOO_LONG_MSG"),
                                    fldList),
                            UIRegistry.getResourceString("Ok"), UIRegistry.getResourceString("Cancel"),
                            JOptionPane.WARNING_MESSAGE);
            if (result) {
                for (SpQueryField fld : flds) {
                    Integer startLen = fld.getStartValue() == null ? 0 : fld.getStartValue().length();
                    Integer endLen = fld.getEndValue() == null ? 0 : fld.getEndValue().length();
                    if (startLen > maxStartLen) {
                        fld.setStartValue("");
                    }
                    if (endLen > maxEndLen) {
                        fld.setEndValue("");
                    }
                }
            }
        }
    }
    return result;
}

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

/**
 * An action event handler invoked when the user presses the start button.
 * Performs some validation checks on the input fields and starts the
 * simulation task. Displays warnings if malformed input is detected.
 * //w  w w  .  j  a  v a  2 s.  com
 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
 */
@Override
public void actionPerformed(ActionEvent e) {
    setSelectedObject((OMBuilding) comboBoxSelectProject.getSelectedItem());
    setProjectName(getSelectedObject().getName());
    if (rdbtnSystematic.isSelected()) {
        setSystematic(true);
        setRandomCampaigns(0);
    } else {
        setSystematic(false);
        setRandomCampaigns((Integer) spnrRandomCampaigns.getValue());
    }
    if (chckbxRatio3.isSelected()) {
        setRatio3((Integer) spnrRatio3.getValue());
    } else {
        setRatio3(0);
    }
    if (chckbxRatio4.isSelected()) {
        setRatio4((Integer) spnrRatio4.getValue());
    } else {
        setRatio4(0);
    }
    if (chckbxRatio5.isSelected()) {
        setRatio5((Integer) spnrRatio5.getValue());
    } else {
        setRatio5(0);
    }
    if (chckbxRatio6.isSelected()) {
        setRatio6((Integer) spnrRatio6.getValue());
    } else {
        setRatio6(0);
    }
    if (chckbxRandomNoise.isSelected()) {
        setRandomNoise((Integer) spnrRandomNoise.getValue());
    } else {
        setRandomNoise(0);
    }

    if (isSystematic) {
        btnStart.setEnabled(false);
        comboBoxSelectProject.setEnabled(false);
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        progressBarSimulation.setStringPainted(true);
        progressBarSimulation.setIndeterminate(false);
        progressBarSimulation.setVisible(true);
        simulationTask = new Simulation();
        simulationTask.execute();
    } else {
        if (txtOmsFile.getText() != null && !txtOmsFile.getText().equals("")
                && !txtOmsFile.getText().equals(" ")) {
            txtOmsFile.setBackground(Color.WHITE);
            String omsPath = txtOmsFile.getText();
            String oms;
            String[] tmpFileName = omsPath.split("\\.");
            if (tmpFileName[tmpFileName.length - 1].equals("oms")) {
                oms = "";
            } else {
                oms = ".oms";
            }
            txtOmsFile.setText(omsPath + oms);
            setOmsFile(omsPath + oms);
            File omsFile = new File(omsPath + oms);
            if (!omsFile.exists()) {
                txtOmsFile.setBackground(Color.WHITE);
                btnStart.setEnabled(false);
                comboBoxSelectProject.setEnabled(false);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                progressBarSimulation.setStringPainted(true);
                progressBarSimulation.setIndeterminate(false);
                progressBarSimulation.setVisible(true);
                simulationTask = new Simulation();
                simulationTask.execute();
            } else {
                txtOmsFile.setBackground(new Color(255, 222, 222, 128));
                JOptionPane.showMessageDialog(null, "This file already exists. Please select another OMS-file!",
                        "Error", JOptionPane.ERROR_MESSAGE);
            }
        } else {
            txtOmsFile.setBackground(new Color(255, 222, 222, 128));
            JOptionPane.showMessageDialog(null, "Please select an OMS-file!", "Warning",
                    JOptionPane.WARNING_MESSAGE);
        }
    }
}

From source file:edu.ku.brc.specify.tasks.WorkbenchTask.java

/**
 * This filters out all non-image files per the image filter and adds them to the Vector.
 * @param files the list of files//from   www.  j  a v  a2 s.  com
 * @param fileList the returned Vector of image files
 * @param imageFilter the filter to use to weed out non-image files
 * @return true if it should continue, false to stop
 */
protected boolean filterSelectedFileNames(final File[] files, final Vector<File> fileList,
        final ImageFilter imageFilter) {
    if (files == null || files.length == 0) {
        return false;
    }

    Hashtable<String, Boolean> badFileExts = new Hashtable<String, Boolean>();

    for (int i = 0; i < files.length; i++) {
        if (files[i].isFile()) {
            String fileName = files[i].getName();
            if (imageFilter.isImageFile(fileName)) {
                fileList.add(files[i]);
            } else {
                badFileExts.put(FilenameUtils.getExtension(fileName), true);
            }
        }
    }

    // No check to see if we had any bad files and warn the user about them
    if (badFileExts.size() > 0) {
        StringBuffer badExtStrBuf = new StringBuffer();
        for (String ext : badFileExts.keySet()) {
            if (badExtStrBuf.length() > 0)
                badExtStrBuf.append(", ");
            badExtStrBuf.append(ext);
        }

        // Now, if none of the files were good we tell them and then quit the import task
        if (fileList.size() == 0) {
            JOptionPane.showMessageDialog(UIRegistry.getMostRecentWindow(),
                    String.format(getResourceString("WB_WRONG_IMG_NO_IMAGES"),
                            new Object[] { badExtStrBuf.toString() }),
                    UIRegistry.getResourceString("WARNING"), JOptionPane.ERROR_MESSAGE);
            return false;

        }

        // So we know we have at least one good image file type
        // So let them choose if they want to continue.
        Object[] options = { getResourceString("Continue"), getResourceString("Stop") };

        if (JOptionPane.showOptionDialog(UIRegistry.getMostRecentWindow(),
                String.format(getResourceString("WB_WRONG_IMG_SOME_IMAGES"),
                        new Object[] { badExtStrBuf.toString() }),
                title, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options,
                options[1]) == JOptionPane.NO_OPTION) {
            return false;
        }
    }
    return true;
}

From source file:UI.MainUI.java

private void startFForecast() {

    BufferedReader br = null;//ww  w .ja  v a  2  s . co m
    List<Double> inputValues = new ArrayList<Double>();
    String currency = "";
    int currencyCol;
    int inputCnt, hiddenCnt, outputCnt;
    double expectedOutput = 0;
    String tableRowData[] = new String[4];
    Double output;

    File testDataFile = new File(testingDataPath.getText());

    currencyCol = CurrencyComboBox.getSelectedIndex() + 1;
    currency = Utility.getCurrency(currencyCol);

    File file = new File("FFresource/" + currency + ".csv");
    FileReader fr;

    String[] cols;
    try {
        br = new BufferedReader(new FileReader(file));
        cols = br.readLine().split(",");
        inputCnt = Integer.parseInt(cols[0]);
        hiddenCnt = Integer.parseInt(cols[1]);
        outputCnt = Integer.parseInt(cols[2]);
        br.close();
        try {

            File testResultFile = new File("FFresource/testing.txt");
            Files.deleteIfExists(testResultFile.toPath());

            br = new BufferedReader(new FileReader(testDataFile));

            int i = 0;
            while (true) {
                readDataFromFile(br, inputCnt, inputValues, currencyCol, tableRowData);

                FFData data = new FFData();
                data.setInputNeurons(inputCnt);
                data.setHiddenNeurons(hiddenCnt);
                data.setOutputNeurons(outputCnt);
                data.setCurrencyCol(currencyCol);
                data.setInputValues(inputValues);

                FForecast task = new FForecast(data);
                output = task.forecast();

                tableRowData[ACTUAL_OUTPUT_COL] = Utility.formatDecimal(output);
                fillTable(tableRowData, i);
                i++;

                try (PrintWriter out = new PrintWriter(
                        new BufferedWriter(new FileWriter("FFresource/testing.txt", true)))) {
                    out.println("intput: " + tableRowData[INPUT_COL]);
                    out.println("Expected Output: " + tableRowData[EXPECTED_OUTPUT_COL]);
                    out.println("Actual: " + output + "\n");
                } catch (IOException e) {
                    System.err.println(e);
                }

            }

        } catch (FileNotFoundException ex) {
            String msg = "File " + testDataFile.getName() + " not found !!";
            JOptionPane.showMessageDialog(Utility.getActiveFrame(), msg, "Error", JOptionPane.WARNING_MESSAGE);
            //DialogBox.setVisible(true);
            // Logger.getLogger(MainUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NumberFormatException ex) {
            String msg = "Error reading " + testDataFile.getName() + ".\nFormat is not correct !!";
            JOptionPane.showMessageDialog(Utility.getActiveFrame(), msg, "Error", JOptionPane.WARNING_MESSAGE);
            //  DialogBox.setVisible(true);
            // Logger.getLogger(MainUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (EOFException e) {
            System.out.println("History data file is completely read.");
        } catch (IOException ex) {
            String msg = "Error reading " + testDataFile.getName() + " !!";
            JOptionPane.showMessageDialog(Utility.getActiveFrame(), msg, "Error", JOptionPane.WARNING_MESSAGE);
            // DialogBox.setVisible(true);
            // Logger.getLogger(MainUI.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            br.close();
        }
    } catch (FileNotFoundException ex) {
        String msg = "Training weights not found for " + currency
                + ".\nMake sure neural network is trained !! ";
        JOptionPane.showMessageDialog(Utility.getActiveFrame(), msg, "Error", JOptionPane.WARNING_MESSAGE);
        //DialogBox.setVisible(true);
        //Logger.getLogger(MainUI.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        String msg = "Error reading weights file for " + currency
                + ".\nMake sure neural network is trained properly !! ";
        JOptionPane.showMessageDialog(Utility.getActiveFrame(), msg, "Error", JOptionPane.WARNING_MESSAGE);
        //DialogBox.setVisible(true);
        // Logger.getLogger(MainUI.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.nikonhacker.gui.EmulatorUI.java

public void startEmulator(final int chip, EmulationFramework.ExecutionMode executionMode, Integer endAddress) {
    //System.err.println("Start request for " + Constants.CHIP_LABEL[chip]);
    framework.prepareBreakTriggers(chip, executionMode, endAddress);
    setStatusText(chip, executionMode.getLabel() + " session in progress...");
    statusBar[chip].setBackground(executionMode == EmulationFramework.ExecutionMode.DEBUG ? STATUS_BGCOLOR_DEBUG
            : STATUS_BGCOLOR_RUN);//from ww  w .ja v a  2  s.  c  o m
    framework.prepareEmulation(chip);
    updateState(chip);
    if (prefs.isSyncPlay()) {
        // Start the other one too
        int otherChip = 1 - chip;
        if (framework.isImageLoaded(otherChip)) {

            setStatusText(otherChip, "Sync play...");
            statusBar[otherChip].setBackground(STATUS_BGCOLOR_RUN);
            EmulationFramework.ExecutionMode altExecutionMode;
            switch (executionMode) {
            case STEP:
                altExecutionMode = prefs.getAltExecutionModeForSyncedCpuUponStep(chip);
                break;
            case DEBUG:
                altExecutionMode = prefs.getAltExecutionModeForSyncedCpuUponDebug(chip);
                break;
            default:
                altExecutionMode = EmulationFramework.ExecutionMode.RUN;
            }
            framework.prepareBreakTriggers(otherChip, altExecutionMode, null);
            setStatusText(otherChip, altExecutionMode.getLabel() + " session in progress...");
            statusBar[otherChip].setBackground(
                    altExecutionMode == EmulationFramework.ExecutionMode.DEBUG ? STATUS_BGCOLOR_DEBUG
                            : STATUS_BGCOLOR_RUN);
            framework.prepareEmulation(otherChip);
            updateState(otherChip);
        } else {
            JOptionPane.showMessageDialog(this, "Cannot start " + Constants.CHIP_LABEL[otherChip]
                    + " in sync because no image is loaded.\nOnly " + Constants.CHIP_LABEL[chip] + " will run.",
                    "Warning", JOptionPane.WARNING_MESSAGE);
        }
    }
    //System.err.println("Requesting clock start");
    framework.getMasterClock().start();
}

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

/**
 * @param rs/*w  w  w  .  ja v a  2s . co m*/
 * @param resultSet
 */
protected void countResultsBack(final RecordSetIFace rs, final java.sql.ResultSet resultSet) {
    try {
        if (resultSet.next()) {
            HashSet<Integer> availableIdList = new HashSet<Integer>();
            do {
                availableIdList.add(resultSet.getInt(1));

            } while (resultSet.next());

            if (availableIdList.size() != rs.getNumItems()) {
                UIRegistry.displayLocalizedStatusBarText("FormViewObj.NOT_ALL_RECS_FOUND");
            }

            if (recordSet == null) {
                recordSet = RecordSetFactory.getInstance().createRecordSet();
            }

            recordSetItemList = new Vector<RecordSetItemIFace>(availableIdList.size());
            for (RecordSetItemIFace rsi : rs.getOrderedItems()) {
                if (availableIdList.contains(rsi.getRecordId())) {
                    recordSetItemList.add(rsi);
                    recordSet.addItem(rsi);
                }
            }
            Object firstDataObj = getDataObjectViaRecordSet(0);
            Vector<Object> tmpList = new Vector<Object>(availableIdList.size() + 5);
            tmpList.add(firstDataObj);
            for (int i = 1; i < recordSetItemList.size(); i++) {
                tmpList.add(null);
            }

            if (mvParent != null) {
                mvParent.setData(tmpList);
                mvParent.setRecordSetItemList(this, tableInfo, recordSetItemList);

            } else {
                setDataObj(tmpList);
            }

        } else {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    JOptionPane.showMessageDialog(UIRegistry.getTopWindow(),
                            getResourceString("NO_RECORD_FOUND"), getResourceString("NO_RECORD_FOUND_TITLE"),
                            JOptionPane.WARNING_MESSAGE);
                }
            });
        }
    } catch (SQLException ex) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JOptionPane.showMessageDialog(UIRegistry.getTopWindow(),
                        getResourceString("ERROR_LOADING_FORM_DATA"),
                        getResourceString("ERROR_LOADING_FORM_DATA_TITLE"), JOptionPane.WARNING_MESSAGE);
            }
        });
    }

}

From source file:UI.MainUI.java

private void startRForecast() {

    BufferedReader br = null;//  ww w.  java2  s. c  om
    List<Double> inputValues = new ArrayList<Double>();
    String currency = "";
    int currencyCol;
    int inputCnt, hiddenCnt1, hiddenCnt2, outputCnt;
    double expectedOutput = 0;
    String tableRowData[] = new String[4];
    Double output;

    File testDataFile = new File(testingDataPath.getText());

    currencyCol = CurrencyComboBox.getSelectedIndex() + 1;
    currency = Utility.getCurrency(currencyCol);

    File file = new File("RNNresource/" + currency + ".csv");
    FileReader fr;

    String[] cols;
    try {
        br = new BufferedReader(new FileReader(file));
        cols = br.readLine().split(",");
        inputCnt = Integer.parseInt(cols[0]);
        hiddenCnt1 = Integer.parseInt(cols[1]);
        hiddenCnt2 = Integer.parseInt(cols[2]);
        outputCnt = Integer.parseInt(cols[3]);
        br.close();
        try {

            File testResultFile = new File("RNNresource/testing.txt");
            Files.deleteIfExists(testResultFile.toPath());

            br = new BufferedReader(new FileReader(testDataFile));

            int i = 0;
            while (true) {
                readDataFromFile(br, inputCnt, inputValues, currencyCol, tableRowData);

                RecurrentData data = new RecurrentData();
                data.setInputNeurons(inputCnt);
                data.setHiddenNeurons1(hiddenCnt1);
                data.setHiddenNeurons2(hiddenCnt2);
                data.setOutputNeurons(outputCnt);
                data.setCurrencyCol(currencyCol);
                data.setInputValues(inputValues);

                RForecast task = new RForecast(data);
                output = task.forecast();

                tableRowData[ACTUAL_OUTPUT_COL] = Utility.formatDecimal(output);
                fillTable(tableRowData, i);
                i++;

                try (PrintWriter out = new PrintWriter(
                        new BufferedWriter(new FileWriter("RNNresource/testing.txt", true)))) {
                    out.println("intput: " + tableRowData[INPUT_COL]);
                    out.println("Expected Output: " + tableRowData[EXPECTED_OUTPUT_COL]);
                    out.println("Actual: " + output + "\n");
                } catch (IOException e) {
                    System.err.println(e);
                }

            }

        } catch (FileNotFoundException ex) {
            String msg = "File " + testDataFile.getName() + " not found !!";
            JOptionPane.showMessageDialog(Utility.getActiveFrame(), msg, "Error", JOptionPane.WARNING_MESSAGE);
            // Logger.getLogger(MainUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NumberFormatException ex) {
            String msg = "Error reading " + testDataFile.getName() + ".\nFormat is not correct !!";
            JOptionPane.showMessageDialog(Utility.getActiveFrame(), msg, "Error", JOptionPane.WARNING_MESSAGE);
            // DialogBox.setVisible(true);
            // Logger.getLogger(MainUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (EOFException e) {
            System.out.println("History data file is completely read.");
        } catch (IOException ex) {
            String msg = "Error reading " + testDataFile.getName() + " !!";
            JOptionPane.showMessageDialog(Utility.getActiveFrame(), msg, "Error", JOptionPane.WARNING_MESSAGE);
            // DialogBox.setVisible(true);
            // Logger.getLogger(MainUI.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            br.close();
        }

    } catch (FileNotFoundException ex) {
        String msg = "Training weights not found for " + currency
                + ".\nMake sure neural network is trained !! ";
        JOptionPane.showMessageDialog(Utility.getActiveFrame(), msg, "Error", JOptionPane.WARNING_MESSAGE);
        //DialogBox.setVisible(true);
        //Logger.getLogger(MainUI.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        String msg = "Error reading weights file for " + currency
                + ".\nMake sure neural network is trained properly !! ";
        JOptionPane.showMessageDialog(Utility.getActiveFrame(), msg, "Error", JOptionPane.WARNING_MESSAGE);
        //DialogBox.setVisible(true);
        // Logger.getLogger(MainUI.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:de.main.sessioncreator.DesktopApplication1View.java

private void saveTestsession() {
    int countSession = 0;
    if (checkTestsession()) {
        Filename = submittedFolder + realFilename;

        //Zusammenbauen des Dateiinhaltes
        String[] content = { wizardtaCharterdynamic.getText(), wizardtaTestsessionAreas.getText(),
                wizardLblstartTime.getText().toLowerCase(), wizardtfNameOfTester.getText(),
                wizardtfDuration.getText(), wizardtfTestDesignExecution.getText(),
                wizardtfSessionSetup.getText(), wizardtfBugInvestigation.getText(),
                wizardtfCharter.getText() + "/" + wizardtfOpportunity.getText(), wizardtaDataFiles.getText(),
                wizardtaTestNotes.getText(), wizardtaBugs.getText(), wizardtaIssues.getText(),
                wizardtaReview.getText() };

        //Datei wegspeichern
        String checkedFilename = fileHelper.checkFileExists(Filename);
        boolean filecreated = fileHelper.createTestsession(checkedFilename, content);
        if (filecreated) {
            JOptionPane.showMessageDialog(wizardTabpDetailsDTBIR, checkedFilename + " saved", "Session saved",
                    JOptionPane.INFORMATION_MESSAGE);
            saveMenuItem.setEnabled(false);
            wizardbtnSave.setEnabled(false);
            wizardbtntopSave.setEnabled(false);
            wizardbtnNew.setVisible(true);
            wizardbtntopNew.setEnabled(true);
            wizardtaTestsessionAreas.removeMouseListener(popupListener2);
        }//from  ww  w  .  j av  a  2 s.c  om
        fileHelper.getSessionList(submittedFolder);
        for (String s : fileHelper.sessionList) {
            if (s.contains(TesterRealname.substring(0, 3))) {
                countSession++;
            }
        }
        if (countSession >= 2) {
            JOptionPane.showMessageDialog(wizardTabpDetailsDTBIR,
                    "Please do a Session-Review.\nThere are " + countSession + " Sessions!", "Session Review",
                    JOptionPane.WARNING_MESSAGE);
        }
    }
}