import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * Define a window with a dialog prompt 
 */

public class Dialog1 extends JFrame {

    public static void main(String[] arguments) {

        new Dialog1("Title of Frame");      //instantiate a dialog window
    }                                       //and pass it a title value


    public Dialog1(String title) {

        setTitle(title);                    //or  super(title)
        setSize(300, 200);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel win = new JPanel();          //create a new panel
        setContentPane(win);                //set contentPane to win panel

        Color c = new Color(200,255,255);   //create an RGB color
        win.setBackground(c);               //set panel background color    

        JLabel entry = new JLabel();        //create a label
        win.add(entry);                     //add the label to window

        setVisible(true);                   //make it visible

        //Pop up a dialog box

        JOptionPane dialog = new JOptionPane();
        String response    = dialog.showInputDialog(null, "Enter a Title for the Window:");

        setTitle(response);                 //write response in title bar
    
        response = response.toUpperCase();  //convert to uppercase

        entry.setText(response);            //write response in label
    }
}