Swing中汉字变成方框问题的解决方法

类别:Java 点击:0 评论:0 推荐:

问题产生原因:

当前使用Java虚拟机在Win2000下显示字体不正确,出现点阵字体。具体原因是Java在改平台下找字体文件出错导致使用默认的西方代码字符集。


解决办法:
 如果您能在您安装tbcs的盘下面找到目录.ZAC_JRE_WIN,则表明您没有安装自己的Java虚拟机。这个目录是个隐藏目录。进入目录lib,按照以下方法修改font.properties.zh文件和font.properties.zh.NT4.0文件:
     1、查找字符串 filename.\u5b8b\u4f53
     将filename.\u5b8b\u4f53 = SIMSUN.TTF修改为filename.\u5b8b\u4f53=SIMSUN.TTC,如果已经是filename.\u5b8b\u4f53=SIMSUN.TTC则修改文filename.\u5b8b\u4f53 = SIMSUN.TTF。
     2、替换所有 WingDings,SYMBOL_CHARSET,NEED_CONVERTED 为 \u5b8b\u4f53,GB2312_CHARSET
     3、替换所有 Symbol,SYMBOL_CHARSET,NEED_CONVERTED 为 \u5b8b\u4f53,GB2312_CHARSET
 
 如果您的机器上安装了自己的虚拟机(请确认您是否运行过JDK*.exe文件安装虚拟机),在您的Programe Files目录里面找到JavaSoft目录,在下面找到JRE\1.2\lib目录,按照以上修改方法修改font.properties.zh文件和font.properties.zh.NT4.0文件。再在您的Jdk目录下面找到jre\lib目录,修改相同文件名的文件。
 
 
 如果嫌麻烦,将以下文本全部覆盖两个文件即可
 
# @(#)font.properties.zh 1.3 98/10/13
#
# AWT Font default Properties for Chinese Windows
#


dialog.plain.0=Arial,ANSI_CHARSET
dialog.plain.1=\u5b8b\u4f53,GB2312_CHARSET
dialog.plain.2=\u5b8b\u4f53,GB2312_CHARSET
dialog.plain.3=\u5b8b\u4f53,GB2312_CHARSET

dialog.bold.0=Arial,ANSI_CHARSET
dialog.bold.1=\u5b8b\u4f53,GB2312_CHARSET
dialog.bold.2=\u5b8b\u4f53,GB2312_CHARSET
dialog.bold.3=\u5b8b\u4f53,GB2312_CHARSET

dialog.italic.0=Arial,ANSI_CHARSET
dialog.italic.1=\u5b8b\u4f53,GB2312_CHARSET
dialog.italic.2=\u5b8b\u4f53,GB2312_CHARSET
dialog.italic.3=\u5b8b\u4f53,GB2312_CHARSET

dialog.bolditalic.0=Arial,ANSI_CHARSET
dialog.bolditalic.1=\u5b8b\u4f53,GB2312_CHARSET
dialog.bolditalic.2=\u5b8b\u4f53,GB2312_CHARSET
dialog.bolditalic.3=\u5b8b\u4f53,GB2312_CHARSET

dialoginput.plain.0=Courier New,ANSI_CHARSET
dialoginput.plain.1=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.plain.2=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.plain.3=\u5b8b\u4f53,GB2312_CHARSET

dialoginput.bold.0=Courier New,ANSI_CHARSET
dialoginput.bold.1=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.bold.2=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.bold.3=\u5b8b\u4f53,GB2312_CHARSET

dialoginput.italic.0=Courier New,ANSI_CHARSET
dialoginput.italic.1=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.italic.2=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.italic.3=\u5b8b\u4f53,GB2312_CHARSET

dialoginput.bolditalic.0=Courier New,ANSI_CHARSET
dialoginput.bolditalic.1=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.bolditalic.2=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.bolditalic.3=\u5b8b\u4f53,GB2312_CHARSET

serif.plain.0=Times New Roman,ANSI_CHARSET
serif.plain.1=\u5b8b\u4f53,GB2312_CHARSET
serif.plain.2=\u5b8b\u4f53,GB2312_CHARSET
serif.plain.3=\u5b8b\u4f53,GB2312_CHARSET

serif.bold.0=Times New Roman,ANSI_CHARSET
serif.bold.1=\u5b8b\u4f53,GB2312_CHARSET
serif.bold.2=\u5b8b\u4f53,GB2312_CHARSET
serif.bold.3=\u5b8b\u4f53,GB2312_CHARSET

serif.italic.0=Times New Roman,ANSI_CHARSET
serif.italic.1=\u5b8b\u4f53,GB2312_CHARSET
serif.italic.2=\u5b8b\u4f53,GB2312_CHARSET
serif.italic.3=\u5b8b\u4f53,GB2312_CHARSET

serif.bolditalic.0=Times New Roman,ANSI_CHARSET
serif.bolditalic.1=\u5b8b\u4f53,GB2312_CHARSET
serif.bolditalic.2=\u5b8b\u4f53,GB2312_CHARSET
serif.bolditalic.3=\u5b8b\u4f53,GB2312_CHARSET

sansserif.plain.0=Arial,ANSI_CHARSET
sansserif.plain.1=\u5b8b\u4f53,GB2312_CHARSET
sansserif.plain.2=\u5b8b\u4f53,GB2312_CHARSET
sansserif.plain.3=\u5b8b\u4f53,GB2312_CHARSET

sansserif.bold.0=Arial,ANSI_CHARSET
sansserif.bold.1=\u5b8b\u4f53,GB2312_CHARSET
sansserif.bold.2=\u5b8b\u4f53,GB2312_CHARSET
sansserif.bold.3=\u5b8b\u4f53,GB2312_CHARSET

sansserif.italic.0=Arial,ANSI_CHARSET
sansserif.italic.1=\u5b8b\u4f53,GB2312_CHARSET
sansserif.italic.2=\u5b8b\u4f53,GB2312_CHARSET
sansserif.italic.3=\u5b8b\u4f53,GB2312_CHARSET

sansserif.bolditalic.0=Arial,ANSI_CHARSET
sansserif.bolditalic.1=\u5b8b\u4f53,GB2312_CHARSET
sansserif.bolditalic.2=\u5b8b\u4f53,GB2312_CHARSET
sansserif.bolditalic.3=\u5b8b\u4f53,GB2312_CHARSET

monospaced.plain.0=\u5b8b\u4f53,GB2312_CHARSET
monospaced.plain.1=\u5b8b\u4f53,GB2312_CHARSET
monospaced.plain.2=\u5b8b\u4f53,GB2312_CHARSET
monospaced.plain.3=\u5b8b\u4f53,GB2312_CHARSET

monospaced.bold.0=\u5b8b\u4f53,GB2312_CHARSET
monospaced.bold.1=\u5b8b\u4f53,GB2312_CHARSET
monospaced.bold.2=\u5b8b\u4f53,GB2312_CHARSET
monospaced.bold.3=\u5b8b\u4f53,GB2312_CHARSET

monospaced.italic.0=\u5b8b\u4f53,GB2312_CHARSET
monospaced.italic.1=\u5b8b\u4f53,GB2312_CHARSET
monospaced.italic.2=\u5b8b\u4f53,GB2312_CHARSET
monospaced.italic.3=\u5b8b\u4f53,GB2312_CHARSET

monospaced.bolditalic.0=\u5b8b\u4f53,GB2312_CHARSET
monospaced.bolditalic.1=\u5b8b\u4f53,GB2312_CHARSET
monospaced.bolditalic.2=\u5b8b\u4f53,GB2312_CHARSET
monospaced.bolditalic.3=\u5b8b\u4f53,GB2312_CHARSET

# name aliases
#
# alias.timesroman=serif
# alias.helvetica=sansserif
# alias.courier=monospaced

# for backword compatibility
timesroman.0=Times New Roman,ANSI_CHARSET
helvetica.0=Arial,ANSI_CHARSET
courier.0=Courier New,ANSI_CHARSET
zapfdingbats.0=WingDings,SYMBOL_CHARSET

# font filenames for reduced initialization time
#
filename.\u5b8b\u4f53=SIMSUN.TTC

filename.Arial=ARIAL.TTF
filename.Arial_Bold=ARIALBD.TTF
filename.Arial_Italic=ARIALI.TTF
filename.Arial_Bold_Italic=ARIALBI.TTF

filename.Courier_New=COUR.TTF
filename.Courier_New_Bold=COURBD.TTF
filename.Courier_New_Italic=COURI.TTF
filename.Courier_New_Bold_Italic=COURBI.TTF

filename.Times_New_Roman=TIMES.TTF
filename.Times_New_Roman_Bold=TIMESBD.TTF
filename.Times_New_Roman_Italic=TIMESI.TTF
filename.Times_New_Roman_Bold_Italic=TIMESBI.TTF

filename.WingDings=WINGDING.TTF
filename.Symbol=SYMBOL.TTF

# Default font definition
#
default.char=2751

# Static FontCharset info.
#
fontcharset.dialog.1=sun.io.CharToByteGBK
fontcharset.dialog.2=sun.awt.windows.CharToByteWingDings
fontcharset.dialog.3=sun.awt.CharToByteSymbol

fontcharset.dialoginput.1=sun.io.CharToByteGBK
fontcharset.dialoginput.2=sun.awt.windows.CharToByteWingDings
fontcharset.dialoginput.3=sun.awt.CharToByteSymbol

fontcharset.serif.1=sun.io.CharToByteGBK
fontcharset.serif.2=sun.awt.windows.CharToByteWingDings
fontcharset.serif.3=sun.awt.CharToByteSymbol

fontcharset.sansserif.1=sun.io.CharToByteGBK
fontcharset.sansserif.2=sun.awt.windows.CharToByteWingDings
fontcharset.sansserif.3=sun.awt.CharToByteSymbol

fontcharset.monospaced.0=sun.io.CharToByteGBK
fontcharset.monospaced.1=sun.io.CharToByteGBK
fontcharset.monospaced.2=sun.awt.windows.CharToByteWingDings
fontcharset.monospaced.3=sun.awt.CharToByteSymbol

# Exclusion Range info.
#
exclusion.dialog.plain.0=0100-f8ff
exclusion.dialog.italic.0=0100-f8ff
exclusion.dialog.bold.0=0100-f8ff
exclusion.dialog.bolditalic.0=0100-f8ff

exclusion.dialoginput.plain.0=0100-f8ff
exclusion.dialoginput.italic.0=0100-f8ff
exclusion.dialoginput.bold.0=0100-f8ff
exclusion.dialoginput.bolditalic.0=0100-f8ff

exclusion.serif.plain.0=0100-f8ff
exclusion.serif.italic.0=0100-f8ff
exclusion.serif.bold.0=0100-f8ff
exclusion.serif.bolditalic.0=0100-f8ff

exclusion.sansserif.plain.0=0100-f8ff
exclusion.sansserif.italic.0=0100-f8ff
exclusion.sansserif.bold.0=0100-f8ff
exclusion.sansserif.bolditalic.0=0100-f8ff

exclusion.monospaced.plain.0=0100-f8ff
exclusion.monospaced.italic.0=0100-f8ff
exclusion.monospaced.bold.0=0100-f8ff
exclusion.monospaced.bolditalic.0=0100-f8ff

# charset for text input
# inputtextcharset=GB2312_CHARSET

本文地址:http://com.8s8s.com/it/it9864.htm