The Java Program: ArabicDigits.java
1 import java.awt.event.*;
2 import java.awt.*;
3 import java.text.*;
4 import javax.swing.*;
5
6 public class ArabicDigits extends JPanel {
7 static JFrame frame;
8
9 public ArabicDigits() {
10 NumberFormat nf = NumberFormat.getInstance();
11 if (nf instanceof DecimalFormat) {
12 DecimalFormat df = (DecimalFormat)nf;
13 DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
14
15 // set the beginning of the range to Arabic digits
16 dfs.setZeroDigit('\u0660');
17 df.setDecimalFormatSymbols(dfs);
18 }
19
20 // create a label with the formatted number
21 JLabel label = new JLabel(nf.format(1234567.89));
22
23 // set the font with a large enough size so we can easily
24 // read the numbers
25 label.setFont(new Font("Lucida Sans", Font.PLAIN, 22));
26 add(label);
27 }
28
29 public static void main(String [] argv) {
30 ArabicDigits panel = new ArabicDigits();
31 frame = new JFrame("Arabic Digits");
32 frame.addWindowListener(new WindowAdapter() {
33 public void windowClosing(WindowEvent e) {System.exit(0);}});
34 frame.getContentPane().add("Center", panel);
35 frame.pack();
36 frame.setVisible(true);
37 }
38 }
39