
-----------------------------------
ilovechicken
Thu Jun 02, 2005 7:47 pm

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

-----------------------------------
Hikaru79
Thu Jun 02, 2005 7:58 pm


-----------------------------------
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 :) Of course, swing must be imported for JOptionPane to be found.

-----------------------------------
ilovechicken
Thu Jun 02, 2005 8:24 pm

heh?
-----------------------------------
swing must be imported? is that like a 
import swing.*; 
or something?

-----------------------------------
wtd
Thu Jun 02, 2005 9:03 pm

Re: heh?
-----------------------------------
swing must be imported? is that like a 
import swing.*; 
or something?

javax.swing.*, actually.

Check out the API reference at java.sun.com.

-----------------------------------
ilovechicken
Thu Jun 02, 2005 10:25 pm

wow
-----------------------------------
wow, that is unbelievably efficient and easy. thanks a lot.
