-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNumberRenderer.java
50 lines (45 loc) · 1.19 KB
/
NumberRenderer.java
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
40
41
42
43
44
45
46
47
48
49
50
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package classesBase;
/**
*
* @author hugo
*/
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() );
}
}