Example usage for javax.swing JOptionPane showInputDialog

List of usage examples for javax.swing JOptionPane showInputDialog

Introduction

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

Prototype

public static String showInputDialog(Component parentComponent, Object message) throws HeadlessException 

Source Link

Document

Shows a question-message dialog requesting input from the user parented to parentComponent.

Usage

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

public void buttonSICUpdate_actionPerformed(ActionEvent event) {
    try {//from  w  w  w.j a v a 2 s  . c  o  m
        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMaximumFractionDigits(2);
        nf.setMinimumFractionDigits(2);
        String answer = nf.format(_precursorChromatogramWindow);
        String newAnswer = JOptionPane.showInputDialog("New value for MS1 SIC tolerance:", answer);
        _precursorChromatogramWindow = (float) Double.parseDouble(newAnswer);

        for (MRMTransition t : _mrmTransitions) {
            t.setGraphData(null);
            for (MRMDaughter d : t.getDaughters().values()) {
                d.setGraphData(null);
            }
        }
        updateChartsAndFields(false);
    } catch (Exception e) {
        ApplicationContext.infoMessage("Bad value for MZ tolerance, please try again");
    }
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

public void buttonPDT_actionPerformed(ActionEvent event) {
    try {/*from   w  w  w . j a v a2  s. com*/
        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMaximumFractionDigits(2);
        nf.setMinimumFractionDigits(2);
        String answer = nf.format(_precursorDiscoveryMzTolerance);
        String newAnswer = JOptionPane.showInputDialog("New value for precursor tolerance:", answer);
        _precursorDiscoveryMzTolerance = (float) Double.parseDouble(newAnswer);
        initStuff();
    } catch (Exception e) {
        ApplicationContext.infoMessage("Bad value for precursor tolerance.");
    }
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

public void buttonDTOL_actionPerformed(ActionEvent event) {
    try {/*from   ww w . j  a  va 2  s. c o  m*/
        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMaximumFractionDigits(4);
        nf.setMinimumFractionDigits(4);
        String answer = nf.format(_daughterMzTolerance);
        String newAnswer = JOptionPane.showInputDialog("New value for product tolerance:", answer);
        _daughterMzTolerance = (float) Double.parseDouble(newAnswer);
        initStuff();
    } catch (Exception e) {
        ApplicationContext.infoMessage("Bad value for product tolerance.");
    }
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

public void menuItemPMin_actionPerformed(ActionEvent event) {
    try {/*from w w  w .ja  v a2 s  .  co m*/
        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMaximumFractionDigits(2);
        nf.setMinimumFractionDigits(2);
        nf.setGroupingUsed(false);
        String answer = nf.format(_minPeakCutoff);
        String newAnswer = JOptionPane.showInputDialog("New value for min peak cutoff:", answer);
        if (newAnswer == null)
            return;
        float newCutoff = Float.parseFloat(newAnswer);
        if (newCutoff > 0.0f) {
            for (MRMTransition mrt : _mrmTransitions) {
                for (MRMDaughter curd : mrt.getDaughters().values()) {
                    if (curd.getBestElutionCurve() != null
                            && curd.getBestElutionCurve().getHighestPointY() < newCutoff) {
                        ((PeaksTableModel) (peaksTable.getModel())).setValueAt(new Boolean(false),
                                curd.getElutionDataTableRow(), peaksData.Accept.colno);
                    }
                }
            }
        }
        _minPeakCutoff = newCutoff;
    } catch (Exception e) {
        ApplicationContext.infoMessage("Failed to change min acceptable peak height: " + e);
    }
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

public void menuItemAMin_actionPerformed(ActionEvent event) {
    try {/*from ww  w  .  ja va2  s.  c o m*/
        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMaximumFractionDigits(2);
        nf.setMinimumFractionDigits(2);
        nf.setGroupingUsed(false);
        String answer = nf.format(_minAreaCutoff);
        String newAnswer = JOptionPane.showInputDialog("New value for min AUC cutoff:", answer);
        if (newAnswer == null)
            return;
        float newCutoff = Float.parseFloat(newAnswer);
        if (newCutoff > 0.0f) {
            for (MRMTransition mrt : _mrmTransitions) {
                for (MRMDaughter curd : mrt.getDaughters().values()) {
                    if (curd.getBestElutionCurve() != null && curd.getBestElutionCurve().getAUC() < newCutoff) {
                        ((PeaksTableModel) (peaksTable.getModel())).setValueAt(new Boolean(false),
                                curd.getElutionDataTableRow(), peaksData.Accept.colno);
                    }
                }
            }
        }
        _minAreaCutoff = newCutoff;
    } catch (Exception e) {
        ApplicationContext.infoMessage("Failed to change min acceptable AUC: " + e);
    }
}

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

private void attachFile() throws IOException, EntityNotFoundException {
    Title root = chooseTitle();//  www  . j  a  v a  2 s . c  o  m
    File file = openFile(ATTACHDIR, null, null);
    String title = JOptionPane.showInputDialog(frame, TextUtil.getText("TITLE"));
    if (title != null) {
        dss.upload(root, Attachment.Type.OTHER, title, file);
    }
}

From source file:my.honeypotadmin.AppMain.java

private void StockRecountActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StockRecountActionPerformed
    try {//w  ww. j  ava 2s  . c  om

        SQLSetup();

        String message = "Name, Initial Stock, Final Stock, Number Purchased, Income\n";
        for (int i = 0; i < Stock[1].length; i++) {
            if (Stock[1][i] != null) {
                int stockDiff = (Integer.valueOf(Stock[4][i]) - Integer.valueOf(Stock[3][i]));
                message += Stock[1][i] + ", " + Stock[4][i] + ", " + Stock[3][i] + ", " + stockDiff + ", $"
                        + ((double) stockDiff * Double.valueOf(Stock[2][i])) + "\n";
            }
        }
        new FileOutputStream("Stock " + dateFormat.format(date) + ".csv", false).close();
        FileWriter fileOut = new FileWriter("Stock " + dateFormat.format(date) + ".csv");
        fileOut.write(message);
        fileOut.flush();
        JOptionPane.showMessageDialog(null, "Stocks are exported to Stock.csv", "Success!",
                JOptionPane.INFORMATION_MESSAGE);

        String StockUPD = "UPDATE Products SET Stock = CASE Name ";
        String StockEnd = "";
        int NewStock = 0;

        for (String item : Stock[1]) {
            if (item != null) {
                NewStock = (int) Integer.valueOf(
                        JOptionPane.showInputDialog("Please enter stock count of item " + item + ".", "0"));
                StockUPD += ("WHEN '" + item + "' THEN '" + NewStock + "' ");
                StockEnd += "'" + item + "', ";
            }
        }

        StockUPD += "END WHERE Name IN (" + StockEnd.substring(0, StockEnd.length() - 2) + ");";

        sql.SQLUpdate(StockUPD);
        sql.SQLUpdate("UPDATE Products SET InitialStock = Stock");

        SQLSetup();
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, ex, "ERROR", JOptionPane.ERROR_MESSAGE);
    }

}

From source file:my.honeypotadmin.AppMain.java

private void AddStockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddStockActionPerformed
    int dialogResult = JOptionPane.showConfirmDialog(this,
            "Are you sure you woud like to add an item to the system?", "Add Item", JOptionPane.YES_NO_OPTION);
    if (dialogResult == 0) {

        String newBarcode = JOptionPane.showInputDialog("Please enter Barcode for new item.", "");

        while (indexOfIntArray(Stock[0], newBarcode) != -1) {
            newBarcode = JOptionPane.showInputDialog("Please enter UNUSED Barcode for new item.", "");
        }//from ww  w  .j  av  a 2  s. c o m

        String newName = JOptionPane.showInputDialog("Please enter Name for new item.", "");
        String newCost = JOptionPane.showInputDialog("Please enter Cost for new item.", "");
        String newStock = JOptionPane.showInputDialog("Please enter Stock Count for new item.", "");

        sql.SQLUpdate("INSERT INTO Products VALUES ('" + newBarcode + "','" + newName + "','" + newCost + "','"
                + newStock + "','" + newStock + "', 0)");

        SQLSetup();
        newBarcode = newName = newCost = newStock = null;

    }
}

From source file:ffx.ui.MainPanel.java

/**
 * Opens a file from the PDB//from  ww  w  .  j  a  v a 2  s.co  m
 */
public void openFromPDB() {
    if (openThread != null && openThread.isAlive()) {
        return;
    }
    String code = JOptionPane.showInputDialog("Enter the PDB Identifier (4 characters)", "");
    if (code == null) {
        return;
    }
    code = code.toLowerCase().trim();
    if (code == null || code.length() != 4) {
        return;
    }
    String fileName = code + ".pdb";
    String path = getPWD().getAbsolutePath();
    File pdbFile = new File(path + File.separatorChar + fileName);
    CompositeConfiguration properties = Keyword.loadProperties(pdbFile);
    forceFieldFilter = new ForceFieldFilter(properties);
    ForceField forceField = forceFieldFilter.parse();
    FFXSystem newSystem = new FFXSystem(pdbFile, "PDB", properties);
    newSystem.setForceField(forceField);
    if (!pdbFile.exists()) {
        String fromURL = pdbForID(code);
        pdbFile = downloadURL(fromURL);
        if (pdbFile == null || !pdbFile.exists()) {
            return;
        }
    } else {
        String message = String.format(" Reading the local copy of the PDB file %s.", pdbFile);
        logger.info(message);
    }
    PDBFilter pdbFilter = new PDBFilter(pdbFile, newSystem, forceField, properties);
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    UIFileOpener openFile = new UIFileOpener(pdbFilter, this);
    if (fileOpenerThreads > 0) {
        openFile.setNThreads(fileOpenerThreads);
    }
    openThread = new Thread(openFile);
    openThread.start();
    setPanel(GRAPHICS);
}

From source file:my.honeypotadmin.AppMain.java

/**
 * @param args the command line arguments
 *//*  w w w  .  jav a2s.  c om*/
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
            
     try {
     for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
     if ("Nimbus".equals(info.getName())) {
     javax.swing.UIManager.setLookAndFeel(info.getClassName());
     break;
     }
     }
     } catch (ClassNotFoundException ex) {
     java.util.logging.Logger.getLogger(AppMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
     } catch (InstantiationException ex) {
     java.util.logging.Logger.getLogger(AppMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
     } catch (IllegalAccessException ex) {
     java.util.logging.Logger.getLogger(AppMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
     } catch (javax.swing.UnsupportedLookAndFeelException ex) {
     java.util.logging.Logger.getLogger(AppMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
     }
     //</editor-fold>
     */
    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            Addr = JOptionPane.showInputDialog("Please enter LAN Address of shopping terminal.", "192.168.0.4");
            if (Addr != null) {
                new AppMain().setVisible(true);
            } else {
                System.exit(0);
            }
        }
    });
}