swing.JTextField java 中的阿拉伯数字
愿你们大家平安。
javas.swing.JTextField 不支持其他语言的数字输入,例如阿拉伯语、希伯来语、中文。我对此进行了很多研究,但找不到解决方案。
我确实需要功能,因为我的整个应用程序基于 Javax.swing 组件。
急需解决方案各位!!!
<块引用>将 JTextField 放在简单的 GUI 上。转到区域设置并选择阿拉伯语(沙特阿拉伯)作为区域设置,并将“数字替换”自定义为“国家”(应用系统范围的阿拉伯数字)。现在转到 java 应用程序并在文本字段中输入数字。该号码不会是阿拉伯语,而是英语。这就是问题所在..
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..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许您可以尝试这个(至少为了寻找线索):
向 AWT TextField 和 Swing JTextField 注册一个 KeyListener,然后查看当您在键盘上键入“1”时收到的内容。
然后,如果您得到不同的代码,您可以检查是否可以编写一个通用事件处理程序来获取所有键并将键 0-9 替换为阿拉伯语语言环境中的匹配代码。
这不是一个完美的解决方案,但它可能会起作用。
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.
注意:这不是问题的答案 - 只是带有代码片段的注释
在 SwingX 中,我们有一个 NumberFormat 未正确显示阿拉伯数字的问题。除了允许客户端代码访问 JXMonthView 的内部以便他们可以手动调整用于数字的 unicode 范围之外,没有任何帮助:
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:
这并不是真正的答案,但这里的 sscce 可能会提出前进的方向。另请参阅支持的语言环境 。
It's not really an answer, but here's an sscce that may suggest a way forward. See also Supported Locales.