my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes Jtextfield is not updating  dynamically(at run time) 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 is not updating  dynamically(at run time)" Watch "Jtextfield is not updating  dynamically(at run time)" New topic
Author

Jtextfield is not updating dynamically(at run time)

Sophiya Behera
Greenhorn

Joined: May 10, 2012
Posts: 18
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

Joined: Jan 08, 2009
Posts: 1398
    
    6

Does this show some thing if you do a System.out.println on the following on entry.getValue()?



Swastik
Sophiya Behera
Greenhorn

Joined: May 10, 2012
Posts: 18
yes, entry.getValue().toString()) is to show the value in hashmap and it's displaying the value.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6


and the above prints the old value not the updated one?
Sophiya Behera
Greenhorn

Joined: May 10, 2012
Posts: 18
yes... you are absolutely right...
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6

Are you calling this method through some background process/thread?
Sophiya Behera
Greenhorn

Joined: May 10, 2012
Posts: 18
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

Joined: Jan 08, 2009
Posts: 1398
    
    6

May be this helps


http://www.coderanch.com/t/334415/GUI/java/JTextField-does-not-refresh
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6

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

Joined: May 10, 2012
Posts: 18
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

Joined: Jan 08, 2009
Posts: 1398
    
    6

Sophiya,

This labelandTextFieldComponent looks like an user defined class, can we have a look on this?
Sophiya Behera
Greenhorn

Joined: May 10, 2012
Posts: 18
here it is...

Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6

The iterator code you pasted above is in RefreshAppendableJPanel class or in some other class, and where are you initializing labelandTextFieldComponent?
Sophiya Behera
Greenhorn

Joined: May 10, 2012
Posts: 18
The iterator code is in a different clas...

Regards
Sophiya
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jtextfield is not updating dynamically(at run time)
 
Similar Threads
hashtable
Collection in java
Class Cast Exception for Map.Entry
Problems printing a Treemap 2nd run
Make HashMap elements fit into an ArrayList