In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to solve Swing and AWT common problems, I believe that most people do not know much, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The Chinese display in the Swing and AWT components of the JAVA program I wrote is a box, but the title can display Chinese normally, and the Chinese language can be displayed normally using System.out.println ("Chinese string").
The solution is as follows:
It may be caused by the fact that JRE's Chinese font is not supported, so add a supported Chinese font solution:
* step:
To download the Chinese font, I use simsun.ttc, which can be found directly in Windows (my system is XP). The simsun.ttc under C:\ WINDOWS\ Fonts can also download the recommended Skynet website: http://file.tianwang.com/cgi-bin/search?word=simsun.ttc
Step 2:
Put the Chinese font simsun.ttc into the Jre font as follows: cd / lib/fonts or cd / jre/lib/fonts,mkdir fallback (fallback represents the folder where the backup language is stored), where is the path where you installed jdk/jre, mine is / usr/lib / jdk1.5. Copy or link a Chinese font to it: ln-s / usr/share/fonts/truetype/simsun.ttf / usr/lib/jdk1.5/jre/lib/fonts/fallback/simsun.ttf
Step 3:
With the above steps, you can encode the display of Chinese in the code as follows: add the following code at the beginning of the main function:
UIManager.put ("Label.font", f); UIManager.put ("Label.foreground", Color.black); UIManager.put ("Button.font", f); UIManager.put ("Menu.font", f); UIManager.put ("MenuItem.font", f); UIManager.put ("List.font", f); UIManager.put ("CheckBox.font", f); UIManager.put ("RadioButton.font", f); UIManager.put ("ComboBox.font", f) UIManager.put ("TextArea.font", f); UIManager.put ("EditorPane.font", f); UIManager.put ("ScrollPane.font", f); UIManager.put ("ToolTip.font", f); UIManager.put ("TextField.font", f); UIManager.put ("TableHeader.font", f)
The above code represents the use of defined "f" fonts for relevant components throughout the program, so that there is no Chinese garbled and the hassle of setting up all components separately.
My default window manager always uses Beryl, and there's nothing wrong with it. Whether it is development (Java) or general applications. When developing Java desktop applications, I usually use SWT,Swing and AWT for a long time. When I use them today, I suddenly find a problem:
Open Beryl to do Swing and AWT when the control can not be displayed, that is, can not draw out, depressed. I went to the Java development community and said that this is a Bug- of JDK6. -! Fortunately, however, the solution is to edit / etc/environment:
Sudo gedit / etc/environment
Add this sentence:
AWT_TOOLKIT= "MToolkit"
Well, the problem can be solved for the time being o (∩ _ ∩) o. Ha ha
These are all the contents of this article entitled "how to solve Swing and AWT FAQs". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.