This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextField not updated from dialog box.

 
chiranjeevi gunturu
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Posts: 20827
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or giving them the same document:

[ November 11, 2008: Message edited by: Rob Prime ]
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20827
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stuff like that happens. Like how I missed out on two scroll bars sharing a model a few weeks ago.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!