Swing control garbled with Chinese, but not with Russian - java

I work with Eclipse & Java.
System.getProperty("file.encoding") == "GBK".
All my Swing UI Labels stored in separate properties files(like messages_ru.properties,messages_sc.properties).
I use native2ascii to convert properties files to get the Unicode.
But one strange thing comes, the label show the Russian correctly,but not correct with the Simple Chinese. My OS supports Simple Chinese.
Anyone has the same question or has some suggestions to find the Reason? If you need more information, I can show you.

Hmm... Find the reason,it is cause by the Font, My app is using the Factory Font("Calibri") which is not support for Simple Chinese.

Related

How to add enters and use a custom font in a JLabel?

Recently, I have attempted to create a textbox that uses a custom font. The problem I had with it though, is that it also requires certain enters in several places. At first, I tried using \n or \r\n, but that didn't work. This lead me to using HTML, but this gave me the problem of my font not loading in. I tried to fix this using several methods, including change the style of the HTML body, like this:
<html><body style="font-family: pixelmix">Text</body></html>
The font in question, pixelmix is an imported font, not installed on the PC. It is, however, known to the program and can be used without HTML. I don't know if HTML can work with uninstalled fonts, but if anyone had any idea on how to get enters AND a custom font, please let me know.

JavaFx application in Windows is not displaying text correctly

So I have an application written in JavaFx 2.2 that has been packaged for linux, mac, and windows. I am getting a strange issue with some of the text fields though. The application will read a file and populate some labels based on whats found in the file. When run on ubuntu or mac we get a result like as you can see we have that special accent character over the c and it looks just fine. However in Windows it shows up like this . Any idea as to why this is happening? I was a bit confused as it is the same exact application on all three. Thanks.
Make sure to specify character encoding when reading the file, in order to avoid using the platform's default encoding, which varies between operating systems. Just by coincidence, the default on Linux and Mac happens to match the file encoding and produces correct output, but you should not rely on it.

How do I use Chinese characters in Java?

I'm trying to use Chinese characters in Java GUI components. I have changed my keyboard output to Chinese and can type in Netbeans in Chinese. Further, I can compile these Java files. However, when I run these programs, the characters are displayed as English question marks. What can I do to change this?
First, you have to make sure that you are compiling with a suitable setting for the encoding option to javac.
Second, you have to be running with a suitable character encoding. In most cases, setting -Dfile.encoding=UTF8 will do it, but it also depends on what sort of program (command line? GUI?) and what environment you're running it in.
I don't think the shortest answer is best here so I recommend you read this excellent blog post on "The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)" by Joel Spolsky.
I think the couple minutes spent reading this will be more than worth it.

IntelliJ and internationalisation: accented characters

I have a java application which has a GUI in both English and French, using the standard Java internationalisation services. I wrote it in JBuilder 2005 on an old machine, and recently upgraded, which has meant changing IDEs. I have finally settled on IntelliJ.
However, it doesn't seem able to handle the accented characters in my ListResourceBundle descendants which contain French. When I first created the IntelliJ project and added my source (which I did manually, to be sure nothing weird was going on behind the scenes), I noticed that all the accented characters had been changed into pairs of characters such as é. I went through the code and corrected all of these, and assumed that the problem was fixed.
But I find on running the (rebuilt) project that the pairs of characters are still showing, instead of the accented characters that I see in my code!
Can someone who has done internationalisation in IntelliJ please tell me what I need to do to fix this?
PS: I'm on the Mac.
Two things --
First, make sure your files are being stored as UTF, and that your source control supports the encoding.
Second, consider using the resource bundle editing support built into IntelliJ http://www.jetbrains.com/idea/features/i18n_support.html
Java resource bundles should only hold ascii and Unicode escape codes
see [http://java.sun.com/developer/technicalArticles/Intl/ResourceBundles/].
e.g. \u00d6ffnen for German Öffnen.
The command line tool native2ascii converts from your native format to ascii plus unicode escape codes. It is a bit of a hassle but not an Intellij but a Java problem.
Note: I use Intellij on a Mac to create programs localized in English, German and Japanese.

Java Locale Font question..?

[EDIT] this happend on OSX with Java 1.5! (but may also happen on Windows!)
It seems japanese users of my Java Swing program cannot write japanese symbols in JTextFields. Actually they can write them but do not see them. They only see blocks which somehow indicates I think that the font does not support these symbols.
I set my own font for various reasons ("Lucida Sans", Font.PLAIN, 12) - which I wouldn't like to change. My questions are:
would the JTextFields show japanese Symbols without me setting this Font?
could I detect which Locale's are fully supported by my Font and only set it in those cases but leave the standard Java font for all other cases like Locale.Japan?
do you have any other suggestions?
Thank you for your help!
would the JTextFields show japanese Symbols without me setting this Font?
Most likely since the JRE will choose the default.
could I detect which Locale's are fully supported by my Font and only set it in those cases but leave the standard Java font for all other cases like Locale.Japan?
Yes, in theory, although easier would be to test if this font can display a locale specific character using the the canDisplay(char) method in Font. If it don't, you may switch to the default.
do you have any other suggestions?
Here's a link on this topic that may help
Do you have a link for your product?
For this very reason, my internationalized application sets its font depending on the locale. To answer your questions:
This probably depends on which version of Windows is being used. Is this the US edition with Japanese fonts installed, or is this the version sold in Japan? I don't know the exact answer to your question, but I expect that the answer is, "It depends."
I don't know of any standard way to do this. I have found a wonderful utility for investigating this kind of thing: BabelMap. This will tell you exactly what characters are supported by any given font.
Other suggestions: Set your font depending on Locale, at least for select Locales.

Categories