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 MainClass extends JPanel {
public MainClass() {
NumberFormat nf = NumberFormat.getInstance();
if (nf instanceof DecimalFormat) {
DecimalFormat df = (DecimalFormat) nf;
DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
// set the beginning of the range to Arabic digits
dfs.setZeroDigit('\u0660');
df.setDecimalFormatSymbols(dfs);
}
JLabel label = new JLabel(nf.format(1234567.89));
label.setFont(new Font("Lucida Sans", Font.PLAIN, 22));
add(label);
}
public static void main(String[] argv) {
MainClass panel = new MainClass();
JFrame frame = new JFrame("Arabic Digits");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add("Center", panel);
frame.pack();
frame.setVisible(true);
}
}
|