Aly Ahmed Mohamed Aly Ahmed Mohamed - 2 months ago 19
Java Question

Change system language in java programming.

there is way to change system language in java programming. I do java dictionary app so I use two jtextfield one for English and other for Arabic I want when focus in English jtextfield system language convert to english and like in jtextfield arabic there any way to do that ?

Answer

Try using this methods:

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

public void setEnglish(JTextField txt) {
    txt.getInputContext().selectInputMethod(new Locale("en", "US"));
    txt.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);    
}