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:de.evaluationtool.gui.EvaluationFrame.java

public void showPrecision() {
    double threshold = 0;
    boolean ok;/*  ww w . j  av a  2  s .c o m*/
    do {
        try {
            String thresholdString = JOptionPane.showInputDialog("Threshold between 0.0 and 1.0: ");
            threshold = Double.valueOf(thresholdString.replace(',', '.'));
            ok = (threshold >= 0 && threshold <= 1);
        } catch (Exception e) {
            ok = false;
        }
    } while (!ok);

    int correctMatches = 0;
    int incorrectMatches = 0;

    for (CellPanel cellPanel : cellPanels) {
        if (cellPanel.link.correctness != null) {
            if (cellPanel.link.confidence >= threshold) {
                if (cellPanel.link.correctness == Correctness.correct) {
                    correctMatches++;
                } else {
                    incorrectMatches++;
                }
            }
        }
    }
    JOptionPane.showMessageDialog(this, "The precision for threshold " + threshold + " is "
            + (correctMatches * 1.0 / (correctMatches + incorrectMatches)));
    //frame.loadReferenceNT(chooser.getSelectedFile(),confidence);
}

From source file:ca.canucksoftware.ipkpackager.IpkPackagerView.java

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
    String input = JOptionPane.showInputDialog("Add a depends:");
    if (input != null && input.length() > 0) {
        depends.add(input);/*from  w  w w .  j  a va2 s  . com*/
        jList2.setListData(depends.toArray());
    }
    t.schedule(new DelayedLoad(), 50);
}

From source file:ca.canucksoftware.ipkpackager.IpkPackagerView.java

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
    String input = JOptionPane.showInputDialog("Add a screenshot URL:");
    if (input != null && input.length() > 0) {
        ssURLs.add(input);/*from   ww  w. j a v a2  s .  c o  m*/
        jList1.setListData(ssURLs.toArray());
    }
    t.schedule(new DelayedLoad(), 50);
}

From source file:com.SE.myPlayer.MusicPlayerGUI.java

private void createPlaylistActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createPlaylistActionPerformed
        String input = JOptionPane.showInputDialog("Enter playlist Name: ");
        if (input == null) {
        } else if (!input.equals("")) {
            int validInput = sd.newTreeNode(input);
            if (validInput == 1) {
                treeReferesh();/*w ww.  j  a  va  2  s.  c o m*/
                DefaultTreeModel model = (DefaultTreeModel) folder_Playlist_Tree.getModel();
                DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
                DefaultMutableTreeNode playlist = (DefaultMutableTreeNode) model.getChild(root, 1);
                DefaultMutableTreeNode newPlaylist = (DefaultMutableTreeNode) model.getChild(playlist,
                        model.getChildCount(playlist) - 1);

                getSongTable(newPlaylist.toString());

                TreeNode[] nodes = model.getPathToRoot(newPlaylist);
                TreePath treepath = new TreePath(nodes);

                folder_Playlist_Tree.setExpandsSelectedPaths(true);
                folder_Playlist_Tree.setSelectionPath(treepath);
                folder_Playlist_Tree.scrollPathToVisible(treepath);

                addJMenuItemsToPopUP();

                lastOpen = input;
                for (ObjectBean list1 : list) {
                    if (list1.getTitle().equals("library")) {
                        list1.setLastOpen(lastOpen);
                    }
                }
            } else {
                createPlaylistActionPerformed(evt);
            }
        } else {
            JOptionPane.showMessageDialog(null, "Please Enter Valid Playlist Name", "Error in Name",
                    JOptionPane.ERROR_MESSAGE);
            createPlaylistActionPerformed(evt);
        }
    }

From source file:edu.uara.gui.tableeditor.ChartGenerationFrame.java

/**
 * group category by adding group key to existing row series labels
 *//*ww  w.  ja  va 2  s .  com*/
private void groupCategory() {
    if (datasetTable.getTableOrder() == TableOrder.BY_COLUMN) {
        JOptionPane.showMessageDialog(this, "Can not group series when colmn orientation is selected!");
        return;
    }
    int[] rows = this.dataviewTable.getSelectedRows();
    int[] cols = this.dataviewTable.getSelectedColumns();
    String name = null;
    for (int i = 0; i < rows.length; i++) {
        if (rows[i] == 0) {
            JOptionPane.showMessageDialog(this, "Row 1 is not used! please select from row 2 and on");
            return;
        }
    }
    if (cols.length > 1 && cols[0] != 0) {
        JOptionPane.showMessageDialog(this, "Please select only the first column!");
        return;
    } else if (rows.length < 2) {
        JOptionPane.showMessageDialog(this, "Please select at least 2 series to group");
        return;
    } else {
        name = JOptionPane.showInputDialog("Please enter group name!");
        if (name == null)
            return;
        datasetTable.addGroupKey(name);
    }
    for (int row : rows) {

        String currentLabel = datasetTable.getValueAt(row, 0).toString();
        String newLabel = name + " " + currentLabel;
        datasetTable.setValueAt(newLabel, row, 0);

    }
}

From source file:edu.uara.gui.tableeditor.ChartGenerationFrame.java

private void groupCategoryByCol() {
    if (datasetTable.getTableOrder() == TableOrder.BY_ROW) {
        JOptionPane.showMessageDialog(this, "Can not group column when row orientation is selected!");
        return;/* w  ww.  jav  a 2 s .c o  m*/
    }
    int[] rows = this.dataviewTable.getSelectedRows();
    int[] cols = this.dataviewTable.getSelectedColumns();
    String name = null;
    for (int i = 0; i < cols.length; i++) {
        if (cols[i] == 0) {
            JOptionPane.showMessageDialog(this, "Column 1 is not used! please select from column 2 and on");
            return;
        }
    }
    if (rows.length > 1 && rows[0] != 0) {
        JOptionPane.showMessageDialog(this, "Please select only the first row!");
        return;
    } else if (cols.length < 2) {
        JOptionPane.showMessageDialog(this, "Please select at least 2 categories to group");
        return;
    } else {
        name = JOptionPane.showInputDialog("Please enter group name!");
        if (name == null)
            return;
        String colNames[] = new String[cols.length];
        for (int i = 0; i < cols.length; i++) {
            try {
                colNames[i] = dataviewTable.getValueAt(0, cols[i]).toString();
            } catch (Exception ex) {
                System.out.println(ex.toString());
            }
        }
        datasetTable.addColGroupKey(name, colNames);
        //datasetTable.addGroupKey(name);
    }

}

From source file:cz.muni.fi.pv168.MainForm.java

private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
    String query = JOptionPane.showInputDialog(localization.getString("find"));

    Search(query);//from  w w  w  .j ava  2  s .c o m
}

From source file:cz.muni.fi.pv168.MainForm.java

private void jMenuItem19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem19ActionPerformed
    String stringID = JOptionPane.showInputDialog("ID");

    try {//from   w  ww.j a  va 2 s  .  c o m
        long id = Long.parseLong(stringID);
        for (Car c : ((CarsTableModel) carTable.getModel()).getCars()) {
            if (c.getID() == id) {
                new CarSwingWorker(CarsActions.REMOVE_CAR, c).execute();
                return;
            }
        }
    } catch (NumberFormatException ex) {
        JOptionPane.showConfirmDialog(jMenu1, ("ID " + localization.getString("must_be_number")),
                localization.getString("invalid_input"), JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE);
    }
}

From source file:cz.muni.fi.pv168.MainForm.java

private void jMenuItem20ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem20ActionPerformed
    String stringID = JOptionPane.showInputDialog("ID");

    try {//w ww.ja va 2  s  .  c  om
        long id = Long.parseLong(stringID);
        for (Customer c : ((CustomersTableModel) customerTable.getModel()).getCustomers()) {
            if (c.getID() == id) {
                new CustomerSwingWorker(CustomersActions.REMOVE_CUSTOMER, c).execute();
                return;
            }
        }
    } catch (NumberFormatException ex) {
        JOptionPane.showConfirmDialog(jMenu1, ("ID " + localization.getString("must_be_number")),
                localization.getString("invalid_input"), JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE);
    }
}

From source file:cz.muni.fi.pv168.MainForm.java

private void jMenuItem21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem21ActionPerformed
    String stringID = JOptionPane.showInputDialog("ID");

    try {//  w  w w.j a  va 2s .  com
        long id = Long.parseLong(stringID);
        for (Rent r : ((RentsTableModel) rentTable.getModel()).getRents()) {
            if (r.getID() == id) {
                new RentalSwingWorker(RentsActions.REMOVE_RENT, r).execute();
                return;
            }
        }
    } catch (NumberFormatException ex) {
        JOptionPane.showConfirmDialog(jMenu1, ("ID " + localization.getString("must_be_number")),
                localization.getString("invalid_input"), JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE);
    }
}