This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assigning floats to JLabels

 
Dave Johnson
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a JLabel that you wish to use for displaying the results of a calculation of two floats, what methods() are use for this?
Thanks, Dave.
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a job for java.text.NumberFormat or maybe java.text.DecimalFormat
 
Dave Johnson
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jose.
The code I used was this: l[i].setText(""+tally[i]);
The I tried earlier was l[i].setText(+tally[i]); and obviously that was no good.
Anyway I'll read the stuff you suggested and thanks again mate.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic