Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jtextfield is not updating dynamically(at run time)

 
Sophiya Behera
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am trying to update jtextfield at runtime with new values, which are fetched from a hashmap. But the jtextfield text is not updating. Please refer to the below code. Please suggest, where i am going wrong. Thanks in advance.



Regards
Sophiya
 
Swastik Dey
Rancher
Posts: 1603
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this show some thing if you do a System.out.println on the following on entry.getValue()?

 
Sophiya Behera
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, entry.getValue().toString()) is to show the value in hashmap and it's displaying the value.
 
Swastik Dey
Rancher
Posts: 1603
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

and the above prints the old value not the updated one?
 
Sophiya Behera
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes... you are absolutely right...
 
Swastik Dey
Rancher
Posts: 1603
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you calling this method through some background process/thread?
 
Sophiya Behera
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will explain the whole scenario. I have a panel containing text fields. I am trying to update the same by fetching new values(text) from a xml file using hashmap. and i am browsing for the xml file(Jfilechooser) in the local system.
 
Swastik Dey
Rancher
Posts: 1603
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be this helps


http://www.coderanch.com/t/334415/GUI/java/JTextField-does-not-refresh
 
Swastik Dey
Rancher
Posts: 1603
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another small thought on this, however doesn't seem to be related to this issue. Once you find a match, and update the textfield, you can always terminate the loop. It seems that there is unnecessary continuation of the loop. Correct me if I am wrong.
 
Sophiya Behera
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Swastik,
Regarding the loop termination, what you said is right. But regarding my issue, i have tried to use threading concept. The panel containing the jtextfields is declared as a customized jpanel. Please refer to the below code and suggest.



Regards
Sophiya
 
Swastik Dey
Rancher
Posts: 1603
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sophiya,

This labelandTextFieldComponent looks like an user defined class, can we have a look on this?
 
Sophiya Behera
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here it is...

 
Swastik Dey
Rancher
Posts: 1603
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The iterator code you pasted above is in RefreshAppendableJPanel class or in some other class, and where are you initializing labelandTextFieldComponent?
 
Sophiya Behera
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The iterator code is in a different clas...

Regards
Sophiya
 
Swastik Dey
Rancher
Posts: 1603
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That means you are probably initializing labelandTextFieldComponent once in class containing the iterator code and once in the panel class. So even if it gets updated in the iterator class, will it get reflected in the panel class? Because these two are different objects. I may be wrong on this, because I am not very sure about your complete work flow.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic