Java JOptionPane Message queryInt(String message, int initialValue)

Here you can find the source of queryInt(String message, int initialValue)

Description

Queries the User for an Integer value using Swing.

License

Open Source License

Parameter

Parameter Description
message a parameter
initialValue a parameter

Exception

Parameter Description
Exception an exception

Declaration

public static int queryInt(String message, int initialValue) throws Exception 

Method Source Code


//package com.java2s;
import javax.swing.JOptionPane;

public class Main {
    /**/*  ww w.j a  v  a  2s.  co  m*/
     * Queries the User for an Integer value using Swing.
     * @param message
     * @param initialValue
     * @return
     * @throws Exception
     */
    public static int queryInt(String message, int initialValue) throws Exception {
        String input = JOptionPane.showInputDialog(message, "" + initialValue);
        if (input == null)
            throw new Exception("Selection aborted");
        return Integer.parseInt(input);
    }
}

Related

  1. popupMessage(String title, String message)
  2. promptForFloat(Component parentComponent, String message, String title, float oldValue)
  3. promptForString(Component parentComponent, String message, String title, String oldValue)
  4. queryBoolean(String message)
  5. queryDouble(String message, double initialValue)
  6. requestPassword(String titulo, String msg)
  7. select(String[] selList, String msg)
  8. show(String title, int type, Object message, Object[] options, Object initialOption)
  9. showActionFailedWithExceptionMessage(final Component parent, final Exception ex)