S
S
Satisfied IT2020-03-01 11:53:20
Java
Satisfied IT, 2020-03-01 11:53:20

Why does this code only work on windows?

There is a form on which the panel is located jPanel1, on this panel there are text fields. There is also a switch jToggleButton. It is necessary that when you click on this switch, the input language on the panel changes. I do it like this:

private void jToggleButtonLangActionPerformed(java.awt.event.ActionEvent evt) {                                                  
        if(jToggleButtonLang.isSelected()){
            jToggleButtonLang.setText("RU");
            jPanel1.getInputContext().selectInputMethod(new Locale("ru", "RU"));
        } else if(jToggleButtonLang.isSelected()==false){
            jToggleButtonLang.setText("EN");
            jPanel1.getInputContext().selectInputMethod(new Locale("en", "US"));
        }
    }

As a result, in windows everything works as intended, but when copying the same file and running it in linux (tested in linux mint), the language does not switch. What is wrong and how to do it right?
Conclusion java -version
in windows
openjdk version "13.0.2" 2020-01-14
OpenJDK Runtime Environment (build 13.0.2+8)
OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)


On Linux
java version "13.0.2" 2020-01-14
Java(TM) SE Runtime Environment (build 13.0.2+8)
Java HotSpot(TM) 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question