Java JOptionPane Message getInt(String message, int min, int max, Integer initialValue)

Here you can find the source of getInt(String message, int min, int max, Integer initialValue)

Description

get Int

License

Open Source License

Declaration

public static int getInt(String message, int min, int max, Integer initialValue) 

Method Source Code


//package com.java2s;
/*/*from  www. j  a va  2  s.c o m*/
 * Copyright (C) 2008-2015 by Holger Arndt
 *
 * This file is part of the Universal Java Matrix Package (UJMP).
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership and licensing.
 *
 * UJMP is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * UJMP is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with UJMP; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA  02110-1301  USA
 */

import javax.swing.JOptionPane;

public class Main {
    public static int getInt(String message, int min, int max) {
        return getInt(message, min, max, null);
    }

    public static int getInt(String message, int min, int max, Integer initialValue) {
        Integer i = null;
        while (i == null) {
            String s = JOptionPane.showInputDialog(message + " (" + min + " to " + max + ")", initialValue);
            try {
                i = Integer.parseInt(s);
            } catch (Exception e) {
            }
        }
        return i;
    }
}

Related

  1. excMsg(String msg, Exception ex)
  2. excMsg(String msg, Throwable t)
  3. exibeMsg(String msg, int tipoMsg)
  4. getIconForType(int messageType)
  5. getInput(String msg, String defaultInput)
  6. getIntegerFromImput(String message, int min, int max)
  7. getIntegerInput(String message)
  8. getJOptionPaneIcon(int jOptionPaneMessageType)
  9. getPassword(String message)