Here you can find the source of showInputInteger(String message)
public static Optional<Integer> showInputInteger(String message)
//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)); } }