Java JOptionPane Message showInputInteger(String message)

Here you can find the source of showInputInteger(String message)

Description

show Input Integer

License

Apache License

Declaration

public static Optional<Integer> showInputInteger(String message) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Optional;
import javax.swing.JOptionPane;

public class Main {
    public static Optional<Integer> showInputInteger(String message) {
        Optional<String> input = showInput(message);
        if (input.isPresent()) {
            try {
                return Optional.of(Integer.valueOf(input.get()));
            } catch (NumberFormatException e) {
                return Optional.empty();
            }//from  w w  w  .  j a  v a 2  s .  c o  m
        } else {
            return Optional.empty();
        }
    }

    public static Optional<String> showInput(String message) {
        return Optional.ofNullable(JOptionPane.showInputDialog(message));
    }
}

Related

  1. showExceptionMessage(Component parentComponent, Exception exception)
  2. showExceptionMessage(Exception e)
  3. showExceptionMessage(Exception e)
  4. showInput(Component parent, String message, String initValue)
  5. showInput(String message)
  6. showInvalidJarPathMessage(String jarPath)
  7. showLog(int type, String title, String message)
  8. showMessage(Component c, String message, String title)
  9. showMessage(Component c, String msg)