Java tutorial
//package com.java2s; import javax.swing.JOptionPane; public class Main { /** * Displays a {@link JOptionPane} as an Input Dialog asking for a required text. * * @param title The title of the dialog. * @return The text written by the user. */ public static String askForRequiredTextUsingInputDialog(String title, String message) { String text = null; while (text == null || text.trim().equals("")) { text = JOptionPane.showInputDialog(null, message, title, JOptionPane.QUESTION_MESSAGE); } return text; } }