This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP 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