我能够在Java中的所有地方显示日文字符,除了主窗口(JFrame)的标题栏。是否有一种方法可以更改标题栏的字体,以便显示日文字符?谢谢。
我正在使用Windows XP。如果这很重要,我也正在使用Java Substance外观。
我能够在Java中的所有地方显示日文字符,除了主窗口(JFrame)的标题栏。是否有一种方法可以更改标题栏的字体,以便显示日文字符?谢谢。
我正在使用Windows XP。如果这很重要,我也正在使用Java Substance外观。
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
public class GlyphCheck
{
public static void main(String[] argv) throws Exception {
final String title = "Testing: \u30CD";
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JFrame frame = new JFrame(title);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
JLabel label = new JLabel(title);
label.setSize(200, 100);
frame.setContentPane(label);
frame.pack();
frame.setVisible(true);
}
});
}
}
JFrame.setDefaultLookAndFeelDecorated(true);
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
UIManager.put( "InternalFrame.titleFont", Resources.jaDefault.deriveFont(16.0f) );
Try it ;)
// Do this before you display any JFrame.
UIManager.put( "Frame.font", new Font( "Japanese", 12, Font.PLAIN ) );
JFrame.setDefaultLookAndFeelDecorated( true );
JFrame frame = new JFrame( title );
我不熟悉Java Substance,但在开发Web应用时遇到过这种情况。基本上,页面内容中的日文、中文和韩文字符会显示出来,但浏览器标题栏中却不会。
这是因为窗口系统控制着标题栏,而不是浏览器。根据kdgregory的评论,听起来你的情况也类似。
为了让窗口系统理解这些字符并不显示不支持的“方框”,你必须确保安装了正确的字符集。对于Windows XP,以下步骤可以解决浏览器标题栏的问题: