wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JTextField not updated from dialog box. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextField not updated from dialog box." Watch "JTextField not updated from dialog box." New topic
Author

JTextField not updated from dialog box.

chiranjeevi gunturu
Ranch Hand

Joined: Mar 02, 2007
Posts: 59
Hi All,
I have a panel on which it has a button and a text box,cost.On clicking on the button i will get a dialog box which is having the same text box,cost.it means both the text fields are refering to the same object,JTextField.

Now if i try to get the value entered on the text box on the dialog screen to the panel screen, the text field on the panel has become invisible. I am able to get the value in the action listner also.

Please help me out.
Thanks in advance,
chiranjeevi gunturu
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

You can add any child component to any parent only once.

Looks like you are trying to synch the two text fields.
You can achieve this desired behavior by creating two text fields, adding a document listener to one of them and updating the second text field using the document notifications.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19679
    
  18

Or giving them the same document:

[ November 11, 2008: Message edited by: Rob Prime ]

SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

Originally posted by Rob Prime:
Or giving them the same document:


[ November 11, 2008: Message edited by: Rob Prime ]


Man,
I can't believe I missed out on this one.
Thanks Rob!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19679
    
  18

Stuff like that happens. Like how I missed out on two scroll bars sharing a model a few weeks ago.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextField not updated from dialog box.