• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextField value is refreshing

 
Amirr Rafique
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers

I am resetting text of JTextField on an event and then calling repaint of its panel but it is not reflecting the new value. Can any one please help

Thanks
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no reason you should have to call repaint... textField.setText("newText"); should handle everything.

Are you sure the reference you're calling setText() on is the same text field that's being displayed?
 
Amirr Rafique
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks dude. It works in one situation but the other scenario that I am experiencing is

I have a JApplet and my JPanel is added in that applet. Now the values are changing when an event is fired at panel but when we resize the Applet's window or some one selects the textField's text; the previous value is restored.

On these acts(resize / selection), applets paint() method is called which is restoring previous values.

Please help me to resolve it

Thanks
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the code? Because there's definitely something getting left out in the description... once a textfield's value changes, it's not going to get changed back to an old value just by doing a repaint...

There's either multiple references getting treated like a single textfield, some weird painting stuff going on, another listener that's setting new values on the textfield, etc...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!