Peace be upon you all.
javas.swing.JTextField does not support numerals of other languages like arabic, hebrew, chinese on input. I have researched a lot on this but I couldnt find a solution.
I really need functionality as my whole application is based on Javax.swing components.
Need solution guys!!!
Put a JTextField on a simple plain GUI. Go to the regional settings and select Arabic (saudia arabia) as locale and customize the 'digit substitution' as 'national' (System wide arabic numerals applied). Now go to the java app and type numbers in the textfield. The number would not be in arabic but in english. This is the problem..
Maybe you could try this (at least for searching for clues):
register a KeyListener with both the AWT TextField and Swing JTextField and see what is received when you type "1" on the keyboard.
Then, if you get different codes, you could possibly check if you can write a general event handler that gets all keys and replace keys 0-9 with the matching code in arabic locale.
Not a perfect solution, but it might work.
Note: this is not an answer to the question - just a comment with a code snippet
In SwingX we had an issue with NumberFormat not showing arabic digits properly. Nothing helped except allowing client code access to the internals of JXMonthView so they could manually adjust the unicode range to use for the digits:
private void adjustFormatSymbols(Locale locale, DecimalFormat df) {
if ("ar".equals(locale.getLanguage())) {
DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
// set the beginning of the range to Arabic digits
dfs.setZeroDigit('\u0660');
df.setDecimalFormatSymbols(dfs);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With