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:biz.wolschon.finance.jgnucash.HBCIImporter.PropertiesHBCICallback.java

/**
 * {@inheritDoc}//from w  w w  .j  a va2s  .  c o m
 */
public void callback(final HBCIPassport passport, final int reason, final String msg, final int datatype,
        final StringBuffer retData) {
    LOGGER.info("callback: reason=" + reason + " msg=\"" + msg + "\" " + "datatype=" + datatype + " "
            + "retData=\"" + retData + "\"");

    switch (reason) {

    case NEED_COUNTRY:
        //if (msg.equals("Lnderkennzeichen (DE fr Deutschland)")) {
        String country = getProperties().getProperty(HBCIImporter.SETTINGS_COUNTRY, "DE");
        retData.setLength(0); // empty the buffer first
        retData.append(country);
        return;
    //}
    case NEED_PT_PIN:
        //if (msg.equals("Bitte geben Sie die PIN fr das PIN/TAN-Verfahren ein")
        //      || msg.equals("Bitte geben Sie die PIN fr das PIN/TAN-Verfahren ein")) {
        String pin = getProperties().getProperty(HBCIImporter.SETTINGS_PIN);
        if (pin == null || pin.trim().length() == 0 || pin.equalsIgnoreCase("(optional)")) {
            pin = JOptionPane.showInputDialog("Your HBCI-PIN:");
        }
        retData.setLength(0); // empty the buffer first
        retData.append(pin);
        return;
    //}
    case NEED_PASSPHRASE_LOAD:
        //  Bitte geben Sie das neue Passwort fr die Sicherung der Passport-Datei ein
        //if (msg.equals("Bitte geben Sie das Passwort fr den Zugriff auf die Passport-Datei ein")
        //      || msg.equals("Bitte geben Sie das Passwort fr den Zugriff auf die Passport-Datei ein")) {
        retData.setLength(0); // empty the buffer first
        retData.append("0000");
        return;
    //}
    case NEED_PASSPHRASE_SAVE:
        //if (msg.equals("Bitte geben Sie das neue Passwort fr die Sicherung der Passport-Datei ein")
        //      || msg.equals("Bitte geben Sie das neue Passwort fr die Sicherung der Passport-Datei ein")) {
        retData.setLength(0); // empty the buffer first
        retData.append("0000");
        return;
    //}
    case NEED_BLZ:
        //if (msg.equals("Bankleitzahl")) {
        retData.setLength(0); // empty the buffer first
        retData.append(getProperties().getProperty(HBCIImporter.SETTINGS_BANKCODE));
        return;
    //}
    case NEED_HOST:
        //if (msg.equals("Hostname/IP-Adresse")) {
        retData.setLength(0); // empty the buffer first
        String property = getProperties().getProperty(HBCIImporter.SETTINGS_SERVER);
        if (property.startsWith("https://")) {
            property = property.substring("https://".length());
        }
        retData.append(property);
        return;
    //}
    case NEED_USERID:
        if (msg.equals("Nutzerkennung")) {
            retData.setLength(0); // empty the buffer first
            retData.append(getProperties().getProperty(HBCIImporter.SETTINGS_ACCOUNT));
            return;
        }
    case NEED_CUSTOMERID:
        if (msg.equals("Kunden-ID")) {
            //retData.setLength(0); // empty the buffer first
            //Feld soll freigelassen werden retData.replace(0, retData.length(), "90246243");
            return;
        }
    case NEED_CONNECTION: // Bitte stellen Sie jetzt die Verbindung zum Internet her
        return;
    case CLOSE_CONNECTION: // Sie knnen die Internetverbindung jetzt beenden
        return;
    case NEED_PT_SECMECH:
        // we don't really care about this but prefer iTan and Einschritt if possible
        // the fallback-case is enough to handle everything anyway.
        if (retData.toString().contains("900:iTAN")) {
            retData.setLength(0); // empty the buffer first
            retData.append("900");
            return;
        }
        if (retData.toString().contains("999:Einschritt")) {
            retData.setLength(0); // empty the buffer first
            retData.append("999");
            return;
        }
        retData.setLength("999".length()); // select whatever method comes first

    default:
        LOGGER.warn("callback: (unhandled) reason=" + reason + " msg=" + msg);

    }

}

From source file:mazewar.Mazewar.java

/**
 * The place where all the pieces are put together.
 *//*from  w  w  w  . j  av a2  s.c om*/
public Mazewar(String zkServer, int zkPort, int port, String name, String game, boolean robot) {
    super("ECE419 Mazewar");
    consolePrintLn("ECE419 Mazewar started!");

    /* Set up parent */
    ZK_PARENT += game;

    // Throw up a dialog to get the GUIClient name.
    if (name != null) {
        clientId = name;
    } else {
        clientId = JOptionPane.showInputDialog("Enter your name");
    }
    if ((clientId == null) || (clientId.length() == 0)) {
        Mazewar.quit();
    }

    /* Connect to ZooKeeper and get sequencer details */
    List<ClientNode> nodeList = null;
    try {
        zkWatcher = new ZkWatcher();
        zkConnected = new CountDownLatch(1);
        zooKeeper = new ZooKeeper(zkServer + ":" + zkPort, ZK_TIMEOUT, new Watcher() {
            @Override
            public void process(WatchedEvent event) {
                /* Release Lock if ZooKeeper is connected */
                if (event.getState() == SyncConnected) {
                    zkConnected.countDown();
                } else {
                    System.err.println("Could not connect to ZooKeeper!");
                    System.exit(0);
                }
            }
        });
        zkConnected.await();

        /* Successfully connected, now create our node on ZooKeeper */
        zooKeeper.create(Joiner.on('/').join(ZK_PARENT, clientId),
                Joiner.on(':').join(InetAddress.getLocalHost().getHostAddress(), port).getBytes(),
                ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);

        /* Get Seed from Parent */
        mazeSeed = Long.parseLong(new String(zooKeeper.getData(ZK_PARENT, false, null)));

        /* Initialize Sequence Number */
        sequenceNumber = new AtomicInteger(zooKeeper.exists(ZK_PARENT, false).getVersion());

        /* Get list of nodes */
        nodeList = ClientNode.sortList(zooKeeper.getChildren(ZK_PARENT, false));
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }

    // Create the maze
    maze = new MazeImpl(new Point(mazeWidth, mazeHeight), mazeSeed);
    assert (maze != null);

    // Have the ScoreTableModel listen to the maze to find
    // out how to adjust scores.
    ScoreTableModel scoreModel = new ScoreTableModel();
    assert (scoreModel != null);
    maze.addMazeListener(scoreModel);

    /* Initialize packet queue */
    packetQueue = new ArrayBlockingQueue<MazePacket>(QUEUE_SIZE);
    sequencedQueue = new PriorityBlockingQueue<MazePacket>(QUEUE_SIZE, new Comparator<MazePacket>() {
        @Override
        public int compare(MazePacket o1, MazePacket o2) {
            return o1.sequenceNumber.compareTo(o2.sequenceNumber);
        }
    });

    /* Inject Event Bus into Client */
    Client.setEventBus(eventBus);

    /* Initialize ZMQ Context */
    context = ZMQ.context(2);

    /* Set up publisher */
    publisher = context.socket(ZMQ.PUB);
    publisher.bind("tcp://*:" + port);
    System.out.println("ZeroMQ Publisher Bound On: " + port);

    try {
        Thread.sleep(100);
    } catch (Exception e) {
        e.printStackTrace();
    }

    /* Set up subscriber */
    subscriber = context.socket(ZMQ.SUB);
    subscriber.subscribe(ArrayUtils.EMPTY_BYTE_ARRAY);

    clients = new ConcurrentHashMap<String, Client>();
    try {
        for (ClientNode client : nodeList) {
            if (client.getName().equals(clientId)) {
                clientPath = ZK_PARENT + "/" + client.getPath();
                guiClient = robot ? new RobotClient(clientId) : new GUIClient(clientId);
                clients.put(clientId, guiClient);
                maze.addClient(guiClient);
                eventBus.register(guiClient);
                subscriber.connect("tcp://" + new String(zooKeeper.getData(clientPath, false, null)));
            } else {
                addRemoteClient(client);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    checkNotNull(guiClient, "Should have received our clientId in CLIENTS list!");

    // Create the GUIClient and connect it to the KeyListener queue
    this.addKeyListener(guiClient);
    this.isRobot = robot;

    // Use braces to force constructors not to be called at the beginning of the
    // constructor.
    /*{
    maze.addClient(new RobotClient("Norby"));
    maze.addClient(new RobotClient("Robbie"));
    maze.addClient(new RobotClient("Clango"));
    maze.addClient(new RobotClient("Marvin"));
    }*/

    // Create the panel that will display the maze.
    overheadPanel = new OverheadMazePanel(maze, guiClient);
    assert (overheadPanel != null);
    maze.addMazeListener(overheadPanel);

    // Don't allow editing the console from the GUI
    console.setEditable(false);
    console.setFocusable(false);
    console.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder()));

    // Allow the console to scroll by putting it in a scrollpane
    JScrollPane consoleScrollPane = new JScrollPane(console);
    assert (consoleScrollPane != null);
    consoleScrollPane
            .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Console"));

    // Create the score table
    scoreTable = new JTable(scoreModel);
    assert (scoreTable != null);
    scoreTable.setFocusable(false);
    scoreTable.setRowSelectionAllowed(false);

    // Allow the score table to scroll too.
    JScrollPane scoreScrollPane = new JScrollPane(scoreTable);
    assert (scoreScrollPane != null);
    scoreScrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Scores"));

    // Create the layout manager
    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    getContentPane().setLayout(layout);

    // Define the constraints on the components.
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 3.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    layout.setConstraints(overheadPanel, c);
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.weightx = 2.0;
    c.weighty = 1.0;
    layout.setConstraints(consoleScrollPane, c);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;
    layout.setConstraints(scoreScrollPane, c);

    // Add the components
    getContentPane().add(overheadPanel);
    getContentPane().add(consoleScrollPane);
    getContentPane().add(scoreScrollPane);

    // Pack everything neatly.
    pack();

    // Let the magic begin.
    setVisible(true);
    overheadPanel.repaint();
    this.requestFocusInWindow();
}

From source file:com.k42b3.neodym.oauth.Oauth.java

public boolean authorizeToken() throws Exception {
    String url;// www  .j  av  a2  s  .  com

    if (this.provider.getAuthorizationUrl().indexOf('?') == -1) {
        url = this.provider.getAuthorizationUrl() + "?oauth_token=" + this.token;
    } else {
        url = this.provider.getAuthorizationUrl() + "&oauth_token=" + this.token;
    }

    URI authUrl = new URI(url);

    if (Desktop.isDesktopSupported()) {
        Desktop desktop = Desktop.getDesktop();

        if (desktop.isSupported(Desktop.Action.BROWSE)) {
            desktop.browse(authUrl);
        } else {
            JOptionPane.showMessageDialog(null, "Visit the following URL: " + authUrl);
        }
    } else {
        JOptionPane.showMessageDialog(null, "Visit the following URL: " + authUrl);
    }

    verificationCode = JOptionPane.showInputDialog("Please enter the verification Code");

    return true;
}

From source file:com.seanmadden.net.fast.FastInterpretype.java

public void clearWindows() {
    boolean windowCleared = false;
    int selected = JOptionPane.showConfirmDialog(null,
            "Would you like to save the current conversation before clearing?", "Save before clearing?",
            JOptionPane.YES_NO_CANCEL_OPTION);
    if (selected == JOptionPane.YES_OPTION) {
        windowCleared = saveLogToFile();
    } else if (selected == JOptionPane.NO_OPTION) {
        windowCleared = true;//from www  . j ava  2s.co m
    }

    if (windowCleared) {
        si.sendRawDataToPort(DataPacket.generateClearConvoPayload());
        mw.clearWindow();
        String username = JOptionPane.showInputDialog("What is your name?");
        si.sendRawDataToPort(DataPacket.generateSignedOnPayload(username));
        mw.acceptText(username + " (you) has signed on.\n");
        mw.setLocalUserName(username);
    }
}

From source file:kevin.gvmsgarch.App.java

private static String getUserName() {
    return JOptionPane.showInputDialog("Enter your gmail address");
}

From source file:de.evaluationtool.gui.EvaluationFrame.java

private String getProperty() {
    if (property == null) {
        setProperty(JOptionPane.showInputDialog("Please type in the property."));
    }//from  w ww  .j a  v a2  s  .  co m
    return property;
}

From source file:edu.ucla.stat.SOCR.analyses.gui.PrincipalComponentAnalysis.java

/**This method defines the specific statistical Analysis to be carried our on the user specified data. ANOVA is done in this case. */
public void doAnalysis() {

    if (dataTable.isEditing())
        dataTable.getCellEditor().stopCellEditing();

    if (!hasExample) {
        JOptionPane.showMessageDialog(this, DATA_MISSING_MESSAGE);
        return;// www  .j  a  v  a 2  s .c  o  m
    }

    Data data = new Data();

    String firstMessage = "Would you like to use all the data columns in this Principal Components Analysis?";
    String title = "SOCR - Principal Components Analysis";
    String secondMessage = "Please enter the column numbers (seperated by comma) that you would like to use.";
    String columnNumbers = "";

    int reply = JOptionPane.showConfirmDialog(null, firstMessage, title, JOptionPane.YES_NO_OPTION);
    if (reply == JOptionPane.YES_OPTION) {
        String cellValue = null;
        int originalRow = 0;

        for (int k = 0; k < dataTable.getRowCount(); k++) {
            cellValue = ((String) dataTable.getValueAt(k, 0));

            if (cellValue != null && !cellValue.equals("")) {
                originalRow++;

            }
        }

        cellValue = null;
        int originalColumn = 0;

        for (int k = 0; k < dataTable.getColumnCount(); k++) {
            cellValue = ((String) dataTable.getValueAt(0, k));

            if (cellValue != null && !cellValue.equals("")) {
                originalColumn++;

            }
        }

        dataRow = originalRow;
        dataColumn = originalColumn;

        String PCA_Data1[][] = new String[originalRow][originalColumn];
        double PCA_Data[][] = new double[originalRow][originalColumn];

        for (int k = 0; k < originalRow; k++)
            for (int j = 0; j < originalColumn; j++) {

                if (dataTable.getValueAt(k, j) != null && !dataTable.getValueAt(k, j).equals("")) {
                    PCA_Data1[k][j] = (String) dataTable.getValueAt(k, j);
                    PCA_Data[k][j] = Double.parseDouble(PCA_Data1[k][j]);
                }
            }

        double PCA_Adjusted_Data[][] = new double[originalRow][originalColumn];
        double column_Total = 0;
        double column_Mean = 0;

        for (int j = 0; j < originalColumn; j++)
            for (int k = 0; k < originalRow; k++) {
                column_Total += PCA_Data[k][j];

                if (k == (originalRow - 1)) {
                    column_Mean = column_Total / originalRow;

                    for (int p = 0; p < originalRow; p++) {
                        PCA_Adjusted_Data[p][j] = PCA_Data[p][j] - column_Mean;
                    }
                    column_Total = 0;
                    column_Mean = 0;
                }
            }

        Covariance cov = new Covariance(PCA_Adjusted_Data);
        RealMatrix matrix = cov.getCovarianceMatrix();

        EigenDecomposition eigenDecomp = new EigenDecomposition(matrix, 0);

        storedData = eigenDecomp;

        RealMatrix eigenvectorMatrix = eigenDecomp.getV();

        EValueArray = eigenDecomp.getRealEigenvalues();

        eigenvectorMatrix = eigenvectorMatrix.transpose();

        double eigenvectorArray[][] = eigenvectorMatrix.getData();

        /*for (int j = 0; j < 3; j++)
            for (int k = 0; k < 3; k++)
            {
                System.out.println(eigenvectorArray[j][k] + " ");
            } */

        Matrix matrix1 = new Matrix(eigenvectorArray);
        Matrix matrix2 = new Matrix(PCA_Adjusted_Data);
        matrix2 = matrix2.transpose();

        Matrix finalProduct = matrix1.times(matrix2);
        finalProduct = finalProduct.transpose();

        double finalArray[][] = finalProduct.getArrayCopy();

        for (int j = 0; j < originalRow; j++)
            for (int k = 0; k < originalColumn; k++) {
                PCATable.setValueAt(finalArray[j][k], j, k);
            }

        xData = new double[originalRow];
        yData = new double[originalRow];

        for (int i = 0; i < originalRow; i++) {
            xData[i] = finalArray[i][0];
        }
        for (int i = 0; i < originalRow; i++) {
            yData[i] = finalArray[i][1];
        }

        dependentHeader = "C1";
        independentHeader = "C2";
    }

    else { // start here
        try {
            columnNumbers = JOptionPane.showInputDialog(secondMessage);
        } catch (Exception e) {
        }

        String columnNumbersFinal = "," + columnNumbers.replaceAll("\\s", "") + ",";

        Vector<Integer> locationOfComma = new Vector<Integer>(100);

        for (int i = 0; i < columnNumbersFinal.length(); i++) {
            char d = columnNumbersFinal.charAt(i);
            if (d == ',')
                locationOfComma.add(i);
        }

        Vector<Integer> vector = new Vector<Integer>(100); // vector containing column selected numbers

        for (int i = 0; i < locationOfComma.size() - 1; i++) {
            String temp = columnNumbersFinal.substring(locationOfComma.get(i) + 1, locationOfComma.get(i + 1));
            if (temp == "")
                continue;
            vector.add((Integer.parseInt(temp) - 1));

        }

        dependentHeader = "C" + (vector.get(0) + 1);
        independentHeader = "C" + (vector.get(1) + 1);

        // System.out.println("Vector size is: " + vector.size() + "\n");                

        String cellValue = null;
        int originalRow = 0;

        for (int k = 0; k < dataTable.getRowCount(); k++) {
            cellValue = ((String) dataTable.getValueAt(k, 0));

            if (cellValue != null && !cellValue.equals("")) {
                originalRow++;

            }
        }

        int originalColumn = vector.size();

        dataRow = originalRow;
        dataColumn = originalColumn;

        String PCA_Data1[][] = new String[originalRow][originalColumn];
        double PCA_Data[][] = new double[originalRow][originalColumn];

        for (int k = 0; k < originalRow; k++)
            for (int j = 0; j < originalColumn; j++) {

                if (dataTable.getValueAt(k, vector.get(j)) != null
                        && !dataTable.getValueAt(k, vector.get(j)).equals("")) {
                    PCA_Data1[k][j] = (String) dataTable.getValueAt(k, vector.get(j));
                    PCA_Data[k][j] = Double.parseDouble(PCA_Data1[k][j]);
                }
            }

        double PCA_Adjusted_Data[][] = new double[originalRow][originalColumn];
        double column_Total = 0;
        double column_Mean = 0;

        for (int j = 0; j < originalColumn; j++)
            for (int k = 0; k < originalRow; k++) {
                column_Total += PCA_Data[k][j];

                if (k == (originalRow - 1)) {
                    column_Mean = column_Total / originalRow;

                    for (int p = 0; p < originalRow; p++) {
                        PCA_Adjusted_Data[p][j] = PCA_Data[p][j] - column_Mean;
                    }
                    column_Total = 0;
                    column_Mean = 0;
                }
            }

        Covariance cov = new Covariance(PCA_Adjusted_Data);
        RealMatrix matrix = cov.getCovarianceMatrix();

        EigenDecomposition eigenDecomp = new EigenDecomposition(matrix, 0);

        storedData = eigenDecomp;

        RealMatrix eigenvectorMatrix = eigenDecomp.getV();

        EValueArray = eigenDecomp.getRealEigenvalues(); // added              

        eigenvectorMatrix = eigenvectorMatrix.transpose();

        double eigenvectorArray[][] = eigenvectorMatrix.getData();

        /*for (int j = 0; j < 3; j++)
            for (int k = 0; k < 3; k++)
            {
                System.out.println(eigenvectorArray[j][k] + " ");
            } */

        Matrix matrix1 = new Matrix(eigenvectorArray);
        Matrix matrix2 = new Matrix(PCA_Adjusted_Data);
        matrix2 = matrix2.transpose();

        Matrix finalProduct = matrix1.times(matrix2);
        finalProduct = finalProduct.transpose();

        double finalArray[][] = finalProduct.getArrayCopy();

        /* for (int j = 0; j < dataTable.getColumnCount(); j++)
            for (int k = 0; k < dataTable.getRowCount(); k++)
            {
                System.out.println(finalArray[j][k] + " ");
            }*/

        for (int j = 0; j < originalRow; j++)
            for (int k = 0; k < originalColumn; k++) {
                PCATable.setValueAt(finalArray[j][k], j, k);
            }

        xData = new double[originalRow];
        yData = new double[originalRow];

        for (int i = 0; i < originalRow; i++) {
            xData[i] = finalArray[i][0];
        }

        for (int i = 0; i < originalRow; i++) {
            yData[i] = finalArray[i][1];
        }
    }

    map = new HashMap<Double, double[]>();

    for (int i = 0; i < dataColumn; i++) {
        map.put(EValueArray[i], storedData.getEigenvector(i).toArray());
    }

    Arrays.sort(EValueArray);

    xData1 = new double[EValueArray.length]; // for Scree Plot
    yData1 = new double[EValueArray.length];

    for (int i = 0; i < EValueArray.length; i++) {
        xData1[i] = i + 1;
    }

    for (int i = 0; i < EValueArray.length; i++) {
        yData1[i] = EValueArray[i];
    }

    for (int i = 0; i < yData1.length / 2; i++) {
        double temp = yData1[i];
        yData1[i] = yData1[yData1.length - i - 1];
        yData1[yData1.length - i - 1] = temp;
    }

    for (int i = 0; i < xData1.length; i++) {
        System.out.println("xData1 contains: " + xData1[i] + "\n");
    }

    for (int i = 0; i < yData1.length; i++) {
        System.out.println("yData1 contains: " + yData1[i] + "\n");
    }

    for (int i = 0; i < EValueArray.length / 2; i++) {
        double temp = EValueArray[i];
        EValueArray[i] = EValueArray[EValueArray.length - i - 1];
        EValueArray[EValueArray.length - i - 1] = temp;
    }

    resultPanelTextArea.append(
            "Click on \"PCA RESULT\" panel to view the transformed data (Eigenvector Transposed * Adjusted Data Transposed)");

    resultPanelTextArea.append("\n\nThe real eigenvalues (in descending order) are: \n\n");
    resultPanelTextArea.append("" + round(EValueArray[0], 3));

    for (int i = 1; i < EValueArray.length; i++) {
        resultPanelTextArea.append("\n" + round(EValueArray[i], 3));
    }
    resultPanelTextArea.append("\n\nThe corresponding eigenvectors (in columns) are: \n\n");

    double temp[] = new double[100];

    for (int j = 0; j < temp.length; j++)
        for (int i = 0; i < EValueArray.length; i++) {
            temp = map.get(EValueArray[i]);
            resultPanelTextArea.append("" + round(temp[j], 3) + "\t");
            if (i == EValueArray.length - 1) {
                resultPanelTextArea.append("\n");
            }
        }

    doGraph();
}

From source file:kevin.gvmsgarch.App.java

private static ContactFilter buildFilter() {
    ContactFilter retval = null;//from w  w w  .  j a v a  2  s. c  o  m

    int optionPaneResult;

    //        optionPaneResult = JOptionPane.showConfirmDialog(null, "Do you want to enable filtering?", "", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
    String[] options = new String[] { "Yes", "No" };

    optionPaneResult = JOptionPane.showOptionDialog(null, "Do you want to enable filtering?", "",
            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]);

    if (optionPaneResult == 0) {
        JOptionPane.showMessageDialog(null, filterExplanation);
        String contactName = JOptionPane
                .showInputDialog("Filter String (contact display name or phone number)");
        if (contactName == null || contactName.trim().isEmpty()) {
            retval = new NullFilter();
        } else {
            if (contactName.trim().equals("Unknown")) {
                retval = new UnknownFilter();
            } else {
                retval = new NameNumberFilter(contactName);
            }
        }
    } else if (optionPaneResult == JOptionPane.NO_OPTION) {
        retval = new NullFilter();

    }

    return retval;
}

From source file:com.smanempat.controller.ControllerEvaluation.java

public void proccessMining(JTable tableDataSetModel, JTable tableDataSetTesting, JTextField txtNumberOfK,
        JLabel labelPesanError, JTabbedPane jTabbedPane1, JTable tableResult, JTable tableConfMatrix,
        JTable tableTahunTesting, JLabel totalAccuracy, JPanel panelChart, JPanel panelChart1,
        JPanel panelChart2, JRadioButton singleTesting, JRadioButton multiTesting, JTextArea txtArea)
        throws SQLException {
    Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
    modelEvaluation = new ModelEvaluation();
    int rowCountModel = tableDataSetModel.getRowCount();
    int rowCountTest = tableDataSetTesting.getRowCount();
    int[] tempK;/*  ww  w.  jav  a  2  s  .  c om*/
    double[][] tempEval;
    double[][] evalValue;
    boolean valid = false;

    /*Validasi Dataset Model dan Dataset Uji*/
    if (rowCountModel == 0) {
        JOptionPane.showMessageDialog(null, "Pilih dataset model terlebih dahulu!", "Error",
                JOptionPane.INFORMATION_MESSAGE,
                new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
        txtNumberOfK.requestFocus();
    } else if (rowCountTest == 0) {
        JOptionPane.showMessageDialog(null, "Pilih dataset uji terlebih dahulu!", "Error",
                JOptionPane.INFORMATION_MESSAGE,
                new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
        txtNumberOfK.requestFocus();
    } else {
        valid = true;
    }
    /*Validasi Dataset Model dan Dataset Uji*/

    if (valid == true) {
        if (multiTesting.isSelected()) {
            String iterasi = JOptionPane.showInputDialog("Input Jumlah Iterasi Pengujian :");
            boolean validMulti = false;

            if (iterasi != null) {

                /*Validasi Jumlah Iterasi*/
                if (Pattern.matches("[0-9]+", iterasi) == false && iterasi.length() > 0) {
                    JOptionPane.showMessageDialog(null, "Nilai iterasi tidak valid!", "Error",
                            JOptionPane.INFORMATION_MESSAGE,
                            new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                } else if (iterasi.isEmpty()) {
                    JOptionPane.showMessageDialog(null, "Nilai iterasi tidak boleh kosong!", "Error",
                            JOptionPane.INFORMATION_MESSAGE,
                            new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                } else if (iterasi.length() == 9) {
                    JOptionPane.showMessageDialog(null, "Nilai iterasi terlalu panjang!", "Error",
                            JOptionPane.INFORMATION_MESSAGE,
                            new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                } else if (rowCountTest > rowCountModel) {

                    JOptionPane.showMessageDialog(null, "Data Uji tidak boleh lebih besar daripada data Model!",
                            "Error", JOptionPane.INFORMATION_MESSAGE,
                            new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                } else {
                    validMulti = true;
                    System.out.println("valiMulti = " + validMulti + " Kok");
                }
                /*Validasi Jumlah Iterasi*/
            }

            if (validMulti == true) {
                tempK = new int[Integer.parseInt(iterasi)];
                evalValue = new double[3][tempK.length];
                for (int i = 0; i < Integer.parseInt(iterasi); i++) {
                    validMulti = false;
                    String k = JOptionPane
                            .showInputDialog("Input Nilai Nearest Neighbor (k) ke " + (i + 1) + " :");
                    if (k != null) {
                        /*Validasi Nilai K Tiap Iterasi*/
                        if (Pattern.matches("[0-9]+", k) == false && k.length() > 0) {
                            JOptionPane.showMessageDialog(null, "Nilai nearest neighbor (k) tidak valid!",
                                    "Error", JOptionPane.INFORMATION_MESSAGE,
                                    new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                        } else if (k.isEmpty()) {
                            JOptionPane.showMessageDialog(null,
                                    "Nilai nearest neighbor (k) tidak boleh kosong!", "Error",
                                    JOptionPane.INFORMATION_MESSAGE,
                                    new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                        } else if (k.length() == 9) {
                            JOptionPane.showMessageDialog(null, "Nilai nearest neighbor (k) terlalu panjang!",
                                    "Error", JOptionPane.INFORMATION_MESSAGE,
                                    new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                        } else {
                            validMulti = true;
                        }
                        /*Validasi Nilai K Tiap Iterasi*/
                    }

                    if (validMulti == true) {
                        tempK[i] = Integer.parseInt(k);
                        System.out.println(tempK[i]);
                    } else {
                        break;
                    }
                }

                if (validMulti == true) {
                    for (int i = 0; i < tempK.length; i++) {
                        int kValue = tempK[i];
                        String[][] modelValue = getModelValue(rowCountModel, tableDataSetModel);
                        double[][] testValue = getTestvalue(rowCountTest, tableDataSetTesting);
                        String[] knnValue = getKNNValue(rowCountModel, rowCountTest, modelValue, testValue,
                                kValue);
                        tempEval = evaluationModel(tableResult, tableConfMatrix, totalAccuracy,
                                tableTahunTesting, tableDataSetTesting, knnValue, i, tempK, panelChart);
                        //Menampung nilai Accuracy
                        evalValue[0][i] = tempEval[0][i];
                        //Menampung nilai Recall
                        evalValue[1][i] = tempEval[1][i];
                        //Menampung nilai Precision
                        evalValue[2][i] = tempEval[2][i];
                        jTabbedPane1.setSelectedIndex(1);
                        txtArea.append(
                                "Tingkat Keberhasilan Sistem dengan Nilai Number of Nearest Neighbor (K) = "
                                        + tempK[i] + "\n");
                        txtArea.append("Akurasi\t\t: " + evalValue[0][i] * 100 + " %\n");
                        txtArea.append("Recall\t\t: " + evalValue[1][i] * 100 + " %\n");
                        txtArea.append("Precision\t: " + evalValue[2][i] * 100 + " %\n");
                        txtArea.append(
                                "=============================================================================\n");
                    }
                    showChart(tempK, evalValue, panelChart, panelChart1, panelChart2);
                }
            }
        } else if (singleTesting.isSelected()) {
            boolean validSingle = false;
            String k = txtNumberOfK.getText();
            int nilaiK = 0;
            evalValue = new double[3][1];

            /*Validasi Nilai Number of Nearest Neighbor*/
            if (Pattern.matches("[0-9]+", k) == false && k.length() > 0) {
                labelPesanError.setText("Number of Nearest Neighbor tidak valid");
                JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak valid!", "Error",
                        JOptionPane.INFORMATION_MESSAGE,
                        new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                txtNumberOfK.requestFocus();
            } else if (k.isEmpty()) {
                JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak boleh kosong!", "Error",
                        JOptionPane.INFORMATION_MESSAGE,
                        new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                labelPesanError.setText("Number of Nearest Neighbor tidak boleh kosong");
                txtNumberOfK.requestFocus();
            } else if (rowCountModel == 0 && Integer.parseInt(k) >= rowCountModel) {
                JOptionPane.showMessageDialog(null, "Pilih dataset model terlebih dahulu!", "Error",
                        JOptionPane.INFORMATION_MESSAGE,
                        new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                txtNumberOfK.requestFocus();
            } else if (rowCountTest == 0 && Integer.parseInt(k) >= rowCountTest) {
                JOptionPane.showMessageDialog(null, "Pilih dataset uji terlebih dahulu!", "Error",
                        JOptionPane.INFORMATION_MESSAGE,
                        new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                txtNumberOfK.requestFocus();
            } else if (Integer.parseInt(k) >= rowCountModel) {
                JOptionPane.showMessageDialog(null,
                        "Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + " !", "Error",
                        JOptionPane.INFORMATION_MESSAGE,
                        new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                txtNumberOfK.requestFocus();
            } else {
                validSingle = true;
                nilaiK = Integer.parseInt(k);
            }
            /*Validasi Nilai Number of Nearest Neighbor*/

            if (validSingle == true) {
                int confirm;
                int i = 0;
                confirm = JOptionPane.showOptionDialog(null, "Yakin ingin memproses data?",
                        "Proses Klasifikasi", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                        null, null);
                if (confirm == JOptionPane.OK_OPTION) {

                    int kValue = Integer.parseInt(txtNumberOfK.getText());
                    String[][] modelValue = getModelValue(rowCountModel, tableDataSetModel);
                    double[][] testValue = getTestvalue(rowCountTest, tableDataSetTesting);
                    String[] knnValue = getKNNValue(rowCountModel, rowCountTest, modelValue, testValue, kValue);
                    tempEval = evaluationModel(tableResult, tableConfMatrix, totalAccuracy, tableTahunTesting,
                            tableDataSetTesting, knnValue, nilaiK, panelChart);
                    evalValue[0][i] = tempEval[0][0];
                    evalValue[1][i] = tempEval[1][0];
                    evalValue[2][i] = tempEval[2][0];
                    jTabbedPane1.setSelectedIndex(1);
                }
                System.out.println("com.smanempat.controller.ControllerEvaluation.proccessMining()OKOKOK");
                showChart(nilaiK, evalValue, panelChart, panelChart1, panelChart2);
                Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
            }
        }
    }

}

From source file:com.floreantpos.config.ui.DatabaseConfigurationDialog.java

private void isAuthorizedToPerformDbChange() {
    DatabaseUtil.initialize();/*from w ww .  j  a va  2s .  c  o m*/

    UserDAO.getInstance().findAll();

    String password = JOptionPane.showInputDialog(Messages.getString("DatabaseConfigurationDialog.9")); //$NON-NLS-1$
    User user2 = UserDAO.getInstance().findUserBySecretKey(password);
    if (user2 == null || !user2.isAdministrator()) {
        POSMessageDialog.showError(this, Messages.getString("DatabaseConfigurationDialog.11")); //$NON-NLS-1$
        return;
    }
}