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(Object message) throws HeadlessException 

Source Link

Document

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

Usage

From source file:org.broad.igv.hic.MainWindow.java

private void getEigenvectorActionPerformed(ActionEvent e) {
    double[] rv;/*from w ww . j a  va2  s  .co m*/
    try {
        String number = JOptionPane.showInputDialog("Which eigenvector do you want to see?");
        int num = Integer.parseInt(number) - 1;

        rv = hic.getEigenvector(num);

        if (rv != null) {
            String str = "";
            for (int i = 0; i < rv.length; i++) {
                str += rv[i] + "\n";

            }
            JTextArea textArea = new JTextArea(str, 20, 20);
            textArea.setEditable(false);
            textArea.selectAll();
            JScrollPane pane = new JScrollPane(textArea);
            JFrame frame = new JFrame("Principal Eigenvector");
            frame.getContentPane().add(pane);
            frame.pack();
            frame.setVisible(true);

        } else {
            System.err.println("No densities available for this file.");
        }

    } catch (InvalidMatrixException error) {
        JOptionPane.showMessageDialog(this, "Unable to calculate eigenvectors after 30 iterations",
                "Eigenvector error", JOptionPane.ERROR_MESSAGE);
    } catch (NumberFormatException error) {
        JOptionPane.showMessageDialog(this, "You must enter a valid number.\n" + error.getMessage(),
                "Eigenvector error", JOptionPane.ERROR_MESSAGE);
    }

}

From source file:org.domainmath.gui.MainFrame.java

private void gotoItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gotoItemActionPerformed
    if (fileTab.getSelectedIndex() >= 0) {
        String s = JOptionPane.showInputDialog("Line Number:");
        RTextScrollPane t = (RTextScrollPane) fileTab.getComponentAt(fileTab.getSelectedIndex());
        RSyntaxTextArea selectedArea = (RSyntaxTextArea) t.getTextArea();
        try {// ww w.jav a2 s. c o  m
            Element element = selectedArea.getDocument().getDefaultRootElement();
            int lineRequested = Integer.parseInt(s);
            int rowCount = element.getElementCount();
            if (lineRequested > rowCount || lineRequested < 0) {

                setVisible(false);
                return;
            }
            Element row = null;
            int firstCharacter = 0;
            int rowNumber = 0;
            for (int i = 0; i < lineRequested; ++i) {
                firstCharacter = getFirstCharacter(row);
                rowNumber = element.getElementIndex(firstCharacter);
                row = element.getElement(rowNumber);
            }
            int lastColumnInRow = row.getEndOffset();
            selectedArea.select(firstCharacter, lastColumnInRow - 1);

        } catch (Exception e) {

        }
    }
}

From source file:org.sikuli.script.SikuliScript.java

public static String input(String msg) {
    return (String) JOptionPane.showInputDialog(msg);
}

From source file:org.zaproxy.zap.extension.multiFuzz.impl.http.HttpFuzzerContentPanel.java

private HttpResultRenamePopupFuzzMenu getResultRename() {
    if (rename == null) {
        rename = new HttpResultRenamePopupFuzzMenu();
        rename.addActionListener(new ActionListener() {
            @Override/*  w w  w . j a v a  2 s .  c  o  m*/
            public void actionPerformed(ActionEvent click) {
                String name = JOptionPane
                        .showInputDialog(Constant.messages.getString("fuzz.result.rename.new"));
                getResultsModel().setValueAt(name, getEntry(rename.getLastEntry()), 0);
            }
        });
    }
    return rename;
}

From source file:pl.otros.logview.gui.message.editor.MessageColorizerBrowser.java

protected void applyMessageColorizer(File f) throws ConfigurationException {
    PropertyPatternMessageColorizer mc = editor.createMessageColorizer();
    String name2 = mc.getName();/*  w  ww  .j a  v  a  2  s.c  o m*/
    while (StringUtils.isBlank(name2)) {
        name2 = JOptionPane.showInputDialog("Enter the message colorizer name.");
        mc.setName(name2);
    }
    mc.setFile(f.getAbsolutePath());
    mc.setTestMessage(editor.getTextToColorize());
    container.addElement(mc);
    jList.setSelectedValue(mc, true);
}