Domanda

I'm faced with a weird issue. My Java application doesn't accept accented characters such as é, è or ê. The Swing component JTextField converts it into e. Furthermore, I cannot insert: ´

It's strange, because it doesn't work with the compiled and packaged application that is intended for distribution to users (JAR file). When I execute my application within Eclipse everything works fine: These characters become accepted.

I checked the used VM encoding on start-up. They were different. The packaged application uses Cp1252 and Eclipse starts it with "ISO-...". The system property "file.encoding" displayed the concerning encoding accordingly. So, I tried to switch the encodings in order to reproduce the issue in Eclipse or fix it in my application. But the result was the same as before.

Do you have any idea what's going on?

È stato utile?

Soluzione

Ok, the issue wasn't caused by Java or any encoding setting. My application hooks all key events. There was one component that consumed the key event for "dead keys". That's why the editor component (or JTextField) didn't receive the key event from event dispatcher.

Altri suggerimenti

There's a bug referenced in OpenJDK bug tracker about this issue with Swing: https://bugs.openjdk.java.net/browse/JDK-8064448.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top