| |
13. 13. 7. 阿拉伯数字 |
|
import java.awt.Font;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class ArabicDigitsI18N extends JPanel {
public ArabicDigitsI18N() {
DecimalFormat df = (DecimalFormat) NumberFormat.getInstance();
DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
dfs.setZeroDigit('\u0660');
df.setDecimalFormatSymbols(dfs);
JLabel label = new JLabel(df.format(1234567.89));
label.setFont(new Font("Lucida Sans", Font.PLAIN, 22));
add(label);
}
public static void main(String[] argv) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add("Center", new ArabicDigitsI18N());
frame.pack();
frame.setVisible(true);
}
}
|
|
|