Java JOptionPane Message promptForString(Component parentComponent, String message, String title, String oldValue)

Here you can find the source of promptForString(Component parentComponent, String message, String title, String oldValue)

Description

Utility function to prompt for new string value

License

Open Source License

Parameter

Parameter Description
message the prompt message
title the dialog title
oldValue the original string value

Return

the new string value

Declaration

static public String promptForString(Component parentComponent, String message, String title, String oldValue) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.Component;

import javax.swing.JOptionPane;

public class Main {
    /**//from w  ww .java 2  s .  co  m
     * Utility function to prompt for new string value
     *
     * @param message  the prompt message
     * @param title    the dialog title
     * @param oldValue the original string value
     * @return the new string value
     */
    static public String promptForString(Component parentComponent, String message, String title, String oldValue) {
        String result = oldValue;
        String newValue = (String) JOptionPane.showInputDialog(parentComponent, message, title,
                JOptionPane.PLAIN_MESSAGE, null, null, oldValue);
        if (newValue != null) {
            result = newValue;
        }
        return result;
    }
}

Related

  1. plain(String title, Object message, JComponent parent)
  2. popup(Component parent, String message, String title)
  3. popupMessage(String message)
  4. popupMessage(String title, String message)
  5. promptForFloat(Component parentComponent, String message, String title, float oldValue)
  6. queryBoolean(String message)
  7. queryDouble(String message, double initialValue)
  8. queryInt(String message, int initialValue)
  9. requestPassword(String titulo, String msg)