在JTextFields中从法语切换到阿拉伯语 [英] switching from French to Arabic in JTextFields

查看:65
本文介绍了在JTextFields中从法语切换到阿拉伯语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含JTextField的表单,其中一些特定于法语,另一些特定于阿拉伯语. 我想从一种语言切换到另一种而不按Alt + Shift键. 解决方案的任何帮助将不胜感激.谢谢,

I have a form which contains JTextFields, some are specific for French and others for Arabic. i want to switch from a language to another without pressing alt+shift key. any help on the solution will be appreciated. thanks,

推荐答案

感谢aymeric的回答,但我找到了解决问题的方法,这是我解决问题的方法:

Thanks aymeric for your answer, but i found a solution for the problem, here is how i resolve the problem:

public void Arabe(JTextField txt) {
    txt.getInputContext().selectInputMethod(new Locale("ar", "SA"));
    txt.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);    
}

public void Français(JTextField txt) {
    txt.getInputContext().selectInputMethod(new Locale("fr","FR"));
    txt.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);    
}

private void txt1_FocusGained(java.awt.event.FocusEvent evt) {                                     
    Arabe(my_textfields1);
}                                    

private void txt2_FocusGained(java.awt.event.FocusEvent evt) {                                        
    Français(mytextfields2);
}          

这篇关于在JTextFields中从法语切换到阿拉伯语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆