-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathNumberRenderer.java
More file actions
39 lines (35 loc) · 971 Bytes
/
NumberRenderer.java
File metadata and controls
39 lines (35 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.text.NumberFormat;
import java.util.Locale;
import javax.swing.SwingConstants;
public class NumberRenderer extends FormatRenderer
{
/*
* Use the specified number formatter and right align the text
*/
public NumberRenderer(NumberFormat formatter)
{
super(formatter);
setHorizontalAlignment( SwingConstants.RIGHT );
}
/*
* Use the default currency formatter for the default locale
*/
public static NumberRenderer getCurrencyRenderer()
{
return new NumberRenderer( NumberFormat.getCurrencyInstance() );
}
/*
* Use the default integer formatter for the default locale
*/
public static NumberRenderer getIntegerRenderer()
{
return new NumberRenderer( NumberFormat.getIntegerInstance() );
}
/*
* Use the default percent formatter for the default locale
*/
public static NumberRenderer getPercentRenderer()
{
return new NumberRenderer( NumberFormat.getPercentInstance() );
}
}