• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Text field default value

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your advice. I will choose forum carefully next time.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic