This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 9990
    
    7

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: 19541
    
  16

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: 9990
    
    7

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: 19541
    
  16

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.
 
Similar Threads
Exam GUI
Dropdown
Accessing dynamic Components
Pass radio button/ text box responses from one page to another
Regarding JTextField