Chinese display in jbuilderx
1. Use Chinese in programming
By default, you cannot use Chinese in writing code, but sometimes we need this. For example, in order to enhance the readability and maintenance, we need to add appropriate annotations.
To solve this problem is actually not difficult. Suppose your operating system is installed in the C drive, then after JBuilderx is installed, there is a file called User_Zh.Properties in C: / Documents and settings / YourName / .primetimex / Open it in the form of text.
There are two lines in this document (Line 238 ~ 239, if you have never modified this file):
Editor.display; fixed_fonts.1 = Courier New
Editor.display; fixed_fonts.2 = lucida sans typewriter
These two fonts are we see in JBuilderx (Tools-> Preferences ...):
If we modify the user_zh.properties document, you can make Editor to display Chinese characters! So this part of User_zh.properties has been rewritten:
Editor.display; fixed_fonts.1 = Courier New
Editor.display; fixed_fonts.2 = lucida sans typewriter
Editor.display; fixed_fonts.3 = Dialoginput
That is to add font Dialoginput. If you want to add more fonts, the format is:
Editor.display; fixed_fonts.4 = fontnamehere
Editor.display; fixed_fonts.5 = fontnamehere
Editor.display; fixed_fonts.6 = fontnamehere
...............
However, it should be noted that the fonts you add must be in Editor.Display; Known_Fonts (this paragraph is under Editor_Display; fixed_fonts) The font is concentrated.
Here, you may have a question, why should you choose a Dialoginput font, not a font like "Song"? This is not because "Song" can't be accepted directly by JBuilderx (this sentence means: if you want to use " If we don't simply write editor.display in user_zh.properties; fixed_fonts.3 = Song, you should use the Unicode code. We know that the 'Song' Unicode is '5b8b', 'body' Unicode code is '4f53'. Therefore, it should be written as: editor.display; fixed_fonts.3 = '/ u5b8b / u4f53'), is not any technical reason, but because in the case of "Song", whether it is Chinese characters, It is also the English characters explicitly not so "friendly". The effect of using the DialoginPut font is also acceptable. Therefore, this font is used here.
After modify User_ZH.Properties, open JBuilderx, Tools-> Preference ..., select Editor-> Display, set the font to your desired font (such as Dialoginput) OK. However, the modification will not take effect immediately. You have to restart JBuilderx See the effect:
2. Use Chinese in the program interface
Even if the settings are used, Chinese in the user interface is undoubtedly a problem. After the above settings, in JBuilder, we can do the following:
In its corresponding source code, we can see similar code:
BtnCompute.setText ("Calculate"); // Here is Chinese characters
However, the effect of compilation execution is:
Solution 1:
Set the font attribute of the component to the "Song", etc., the font that truly support Chinese (unfortunately Dialoginput is not such a font), it can be displayed normally. As shown in the figure below: The author found in the experiment, not need to set all components FONT attribute. Only one component's font property is set, all components get the correct display. For example, only the Font property of the JTextField object is set in the above program, without setting the Font property of the Calculation button, but Work well:
It is worth mentioning that at least there is a component set the correct font attribute, otherwise it will not produce your expectations.
Workaround 2: Configuring new JDK for JBuilderx
JBUILDERX default JDK is JDK for Java Version 1.4.2_01-b06. Film test found that if you use Java Version 1.4.2-B28 (of course, it is also possible to limit the time relationship, the author does not invest too much energy in other versions Testing), you can solve Chinese explicit problems on this interface.
From the menu Tools-> Configure JDKs, you can add a new JDK for JBuilderx. The following is a added rendering:
Among them, the selected JDK is a new JDK. Of course, in addition to adding, you have to configure it, make them use the new JDK. Select Project-> Project Properties ..., pop up the following dialog:
Click on the browsing button behind JDK to select the newly added JDK. If you expect all Project, you can select Project-> Default Project Properties ... for the same configuration.
After the configuration is complete, recompile the run, below for its rendering:
By the way, JBuilderx uses 11PT font by default, and the display effect is good in the interface display, which is good. But, it is obvious that you are not willing to set its font size for each component. You can come Do: Tools-> Preferences: