Computer Science Canada

dialog box

Author:  ilovechicken [ Thu Jun 02, 2005 7:47 pm ]
Post subject:  dialog box

i was just wondering if anyone can help me out creating a dialog box that allows the user to enter a string (ie. their name) and then closes when they are done

Author:  Hikaru79 [ Thu Jun 02, 2005 7:58 pm ]
Post subject: 

Java:
String s = (String)JOptionPane.showInputDialog(null,"What is your name?",
                    "Answer me these questions three!",
                    JOptionPane.PLAIN_MESSAGE,
                    null,
                    null,
                    "ilovechicken");
       System.out.println(s);

There you go Smile Of course, swing must be imported for JOptionPane to be found.

Author:  ilovechicken [ Thu Jun 02, 2005 8:24 pm ]
Post subject:  heh?

swing must be imported? is that like a
import swing.*;
or something?

Author:  wtd [ Thu Jun 02, 2005 9:03 pm ]
Post subject:  Re: heh?

ilovechicken wrote:
swing must be imported? is that like a
import swing.*;
or something?


javax.swing.*, actually.

Check out the API reference at java.sun.com.

Author:  ilovechicken [ Thu Jun 02, 2005 10:25 pm ]
Post subject:  wow

wow, that is unbelievably efficient and easy. thanks a lot.


: