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

Formatting JLabel text

Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

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: 289

I got it we can use

String.format("%10.2f",1234.3f);

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
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: 289

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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Formatting JLabel text