Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextField and decimal number

 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to print out a decimal number like 13.45 in JTextField. I do convert this number from a Double to String and send it to JTextField, but in the applet all I get is 1345 followed by a small square. I tried to type 13.45 in the text field, but it does not let me print "." What should I do? Should I use another component to display decimal numbers?
thanks,
Alex
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JTextField is fine. How are you converting to a String. Are you using DecimalFormat or just doing a toString? You should use the DecimalFormat to control how you want the number to appear.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic