• Post Reply Bookmark Topic Watch Topic
  • New Topic

Text field default value  RSS feed

 
kenron max
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I am a new beginner in Java. Currently I'm having problem with the value in text field. But I'm not good in explain. So I will use example.

I had created 2 text fields A and B. Default value in Text Field B is 10. When I changed the value 10 to 4 and click on Text Field A, the value become 4.0000. After that, when I click back on Text Field B, It automatically change back to value 10. But I want preserve the value become 4.

May I know why such thing happened? Is it cause by lostfocus method or field validation method or other ? How can I solve this?

Thanks in advance. Cheers
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. A Text Field, whether that's a TextField or a JTextField holds a String. So the content can never be 10, it can be "10"

2. Whatever behavior you describe is what your code does. Do you seriously think members here can guess enough about that code to give you any meaningful advice? Recommended reading: http://catb.org/~esr/faqs/smart-questions.html and http://mindprod.com/jgloss/sscce.html

And welcome to the Ranch!
 
kenron max
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your advice. I will choose forum carefully next time.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have added some listeners to those text fields. Without seeing what those listeners do we cannot tell you what's going wrong. That's why Darryl asked for an SSCCE.
 
Cyrus Poh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kenron max wrote:Thanks for your advice. I will choose forum carefully next time.


Hey kenron, don't be upset, Darryl Burke is guiding you how to post your question here. Without those information we are hard to troubleshooting for you.

What my advice is, don't give up......keep going

Last, i want to wish "all da best for U"
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cyrus Poh wrote: . . . "all da best for U"
Careful: that's a good way to get me to guide you "how to post your question here"
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!