| Author |
Formatting JLabel text
|
Chiranjeevi Kanthraj
Ranch Hand
Joined: Feb 18, 2008
Posts: 283
|
|
Hi all
I have a JLabel which show some Values like Max, Min and Avg values
i have added the JLabel text in the form of HTML which shows as below
Max : 10.4
Min :0.12
Avg : 123.34
So i have to format this string like
not able to format in this editor
This we can do using System.out.format("%10.2f",value);
But how can take that formated string to JLabel text. is any other way to achive this?
|
-Chiru
|
 |
Chiranjeevi Kanthraj
Ranch Hand
Joined: Feb 18, 2008
Posts: 283
|
|
I got it we can use
String.format("%10.2f",1234.3f);
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32651
|
|
You must have copied those figures from a Government publication if the average is larger than the maximum
But, joking aside, why are you using floats?
|
 |
Chiranjeevi Kanthraj
Ranch Hand
Joined: Feb 18, 2008
Posts: 283
|
|
Just i posted my test code..
And one more issue i am facing now.
the same text is taking more space in Chinese locale. because of the Font
How can i make the format string based on the Font?
So that it should not look odd in the different locale.
|
 |
 |
|
|
subject: Formatting JLabel text
|
|
|