aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Assigning floats to JLabels Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Assigning floats to JLabels" Watch "Assigning floats to JLabels" New topic
Author

Assigning floats to JLabels

Dave Johnson
Ranch Hand

Joined: May 25, 2003
Posts: 111
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

Joined: Jul 03, 2001
Posts: 2120
This is a job for java.text.NumberFormat or maybe java.text.DecimalFormat


SCJP2. Please Indent your code using UBB Code
Dave Johnson
Ranch Hand

Joined: May 25, 2003
Posts: 111
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assigning floats to JLabels