jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes Frame and Dialog problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Frame and Dialog problem" Watch "Frame and Dialog problem" New topic

Frame and Dialog problem

tee ming

Joined: Jul 11, 2001
Posts: 8
I have a program consists of 1 frame and 1 diolog, how can i link them together so that i can get the value in Dialog and set it into textField in Frame.
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
From your JFrame code, make a call like this...
String value = JOptionPane.showInputDialog(....)
You dont need to create your own custom dialog since JOptionPane does it for you. The method showInputDialog() is overloaded to accomodate different arguments, such as dialog title, dialog message, etc. In any event, a call to this static method will display a dialog window to the user with a text field to enter data. After the user clicks OK, the data they entered in the text field will be assigned to the 'value' variable in the code snippet above.
Hope it helps
tee ming

Joined: Jul 11, 2001
Posts: 8
I can't use the default dialog box because my dialog box need to have more than 1 textField and a passwordField. So can you help me solve the previous probelm, Thanks!
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

your name is not in accordance with the javaranch guidelines.
Please take a moment and re-register after selecting a valid
name. you can find the guidelines at http://www.javaranch.com/name.jsp
thanks for your cooperation.
- satya

Take a Minute, Donate an Hour, Change a Life
I agree. Here's the link: http://aspose.com/file-tools
subject: Frame and Dialog problem
It's not a secret anymore!