Q:

Java. How to wait?

I call a class that creates a jframe and waits from user to input some values. 
The problem that I experience is that I need to wait these values before to continue.
So the code is something simple like this
Jframe frame= new jframe(); //here I want the program to show the frame and then wait till   it will be disposed
// I want a pause here 
System.out.println(frame.getvalue);

Till now the only I could do is to froze the frame before can even appear totally.
Any help?
Please keep it simple since I am new to Java.
THANK YOU!

A:

I think you should use JDialog instead of JFrame. Please follow this example

A:

What you're probably looking for is JOptionPane.  This is a blocking routine that returns only after the user has entered some value, like so:
public class test
{
  public static void main ( String args[] )
  {
      String input = JOptionPane.showInputDialog(null, "Thing: ",
                    "Enter Stuff", JOptionPane.OK_CANCEL_OPTION);

      System.out.println ( "won't reach until got input");
      System.out.println ( "My value: " + input );
  }
}

The great thing about it is you can add Components to it, so you aren't limited to a single input field, but it is still blocking.  The following would add two JTextField's to the frame:
public class test
{
    public static void main ( String args[] )
    {
        JTextField input_box = new JTextField(7);
        JTextField input_box2 = new JTextField(7);

        JComponent[] inputs = new JComponent[] {
            new JLabel("Thing 1:"),
            input_box,
            new JLabel("Thing 2:"),
            input_box2 };

        int rval = JOptionPane.showConfirmDialog(null, inputs,
                    "Enter Stuff", JOptionPane.OK_CANCEL_OPTION);

        if ( rval == 0)
        {
           System.out.printf ("%s and %s!", input_box.getText(),
                                         input_box2.getText());
        }
    }
}

A:

Instead of using a JFrame, consider using a JDialog with modality set to true.
When it comes time to add an 'OK' button or something like that, check out JRootPane.setDefaultButton()

