大家常常說JBuilder在中文系統中存在光標錯位的問題,都認為這是JBuilder的一個Bug,其實這實在是冤枉JBuilder了!大家討論出來的解決方法無外乎兩種:
1、將編輯器的字體改為宋體,用這種方法帶來的問題是,在宋體下的英文字體實在難看,閱讀起來不太順眼;
2、就是將編輯器字體的粗體屬性去掉,這樣也影響代碼的可讀性。
其實,造成JBuilder光標錯位的問題並不是Borland的錯誤,而是Java的宗師——Sun的罪過!大家一定知道i18n吧?在不同的區域設置中,JDK自動調用與之相對應的properties文件,而在JDK中,Sun所推出的與中文系統相對應的properties文件存在問題,在它之中沒有區分英文字體的正常、粗體和斜體,從而導致了以上所說的問題,解決的方法很簡單,只要將這個properties文件修改正確就可以了,修改方法如下:
在jre/lib目錄中找到font.properties.zh文件,編輯這個文件並修改成如下內容:
# @(#)font.properties.zh1.16 00/10/06
#
# AWT Font default Properties for Chinese Windows
#
dialog.plain.0=Arial,ANSI_CHARSET
dialog.plain.1=\u5b8b\u4f53,GB2312_CHARSET
dialog.plain.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
dialog.plain.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
dialog.bold.0=Arial Bold,ANSI_CHARSET
dialog.bold.1=\u5b8b\u4f53,GB2312_CHARSET
dialog.bold.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
dialog.bold.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
dialog.italic.0=Arial Italic,ANSI_CHARSET
dialog.italic.1=\u5b8b\u4f53,GB2312_CHARSET
dialog.italic.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
dialog.italic.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
dialog.bolditalic.0=Arial Bold Italic,ANSI_CHARSET
dialog.bolditalic.1=\u5b8b\u4f53,GB2312_CHARSET
dialog.bolditalic.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
dialog.bolditalic.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
dialoginput.plain.0=Courier New,ANSI_CHARSET
dialoginput.plain.1=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.plain.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
dialoginput.plain.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
dialoginput.bold.0=Courier New Bold,ANSI_CHARSET
dialoginput.bold.1=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.bold.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
dialoginput.bold.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
dialoginput.italic.0=Courier New Italic,ANSI_CHARSET
dialoginput.italic.1=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.italic.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
dialoginput.italic.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
dialoginput.bolditalic.0=Courier New Bold Italic,ANSI_CHARSET
dialoginput.bolditalic.1=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.bolditalic.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
dialoginput.bolditalic.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
serif.plain.0=Times New Roman,ANSI_CHARSET
serif.plain.1=\u5b8b\u4f53,GB2312_CHARSET
serif.plain.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
serif.plain.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
serif.bold.0=Times New Roman Bold,ANSI_CHARSET
serif.bold.1=\u5b8b\u4f53,GB2312_CHARSET
serif.bold.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
serif.bold.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
serif.italic.0=Times New Roman Italic,ANSI_CHARSET
serif.italic.1=\u5b8b\u4f53,GB2312_CHARSET
serif.italic.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
serif.italic.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
serif.bolditalic.0=Times New Roman Bold Italic,ANSI_CHARSET
serif.bolditalic.1=\u5b8b\u4f53,GB2312_CHARSET
serif.bolditalic.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
serif.bolditalic.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
sansserif.plain.0=Arial,ANSI_CHARSET
sansserif.plain.1=\u5b8b\u4f53,GB2312_CHARSET
sansserif.plain.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
sansserif.plain.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
sansserif.bold.0=Arial Bold,ANSI_CHARSET
sansserif.bold.1=\u5b8b\u4f53,GB2312_CHARSET
sansserif.bold.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
sansserif.bold.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
sansserif.italic.0=Arial Italic,ANSI_CHARSET
sansserif.italic.1=\u5b8b\u4f53,GB2312_CHARSET
sansserif.italic.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
sansserif.italic.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
sansserif.bolditalic.0=Arial Bold Italic,ANSI_CHARSET
sansserif.bolditalic.1=\u5b8b\u4f53,GB2312_CHARSET
sansserif.bolditalic.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
sansserif.bolditalic.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
monospaced.plain.0=Courier New,GB2312_CHARSET
monospaced.plain.1=\u5b8b\u4f53,GB2312_CHARSET
monospaced.plain.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
monospaced.plain.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
monospaced.bold.0=Courier New Bold,GB2312_CHARSET
monospaced.bold.1=\u5b8b\u4f53,GB2312_CHARSET
monospaced.bold.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
monospaced.bold.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
monospaced.italic.0=Courier New Italic,GB2312_CHARSET
monospaced.italic.1=\u5b8b\u4f53,GB2312_CHARSET
monospaced.italic.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
monospaced.italic.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
monospaced.bolditalic.0=Courier New Bold Italic,GB2312_CHARSET
monospaced.bolditalic.1=\u5b8b\u4f53,GB2312_CHARSET
monospaced.bolditalic.2=WingDings,SYMBOL_CHARSET,NEED_CONVERTED
monospaced.bolditalic.3=Symbol,SYMBOL_CHARSET,NEED_CONVERTED
# name aliases
#
#alias.timesroman=serif
#alias.helvetica=sansserif
#alias.courier=monospaced
# for backward 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.TTF
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.0=sun.io.CharToByteCp1252
fontcharset.dialog.1=sun.io.CharToByteGBK
fontcharset.dialog.2=sun.awt.windows.CharToByteWingDings
fontcharset.dialog.3=sun.awt.CharToByteSymbol
#fontcharset.dialoginput.0=sun.io.CharToByteCp1252
fontcharset.dialoginput.1=sun.io.CharToByteGBK
fontcharset.dialoginput.2=sun.awt.windows.CharToByteWingDings
fontcharset.dialoginput.3=sun.awt.CharToByteSymbol
#fontcharset.serif.0=sun.io.CharToByteCp1252
fontcharset.serif.1=sun.io.CharToByteGBK
fontcharset.serif.2=sun.awt.windows.CharToByteWingDings
fontcharset.serif.3=sun.awt.CharToByteSymbol
#fontcharset.sansserif.0=sun.io.CharToByteCp1252
fontcharset.sansserif.1=sun.io.CharToByteGBK
fontcharset.sansserif.2=sun.awt.windows.CharToByteWingDings
fontcharset.sansserif.3=sun.awt.CharToByteSymbol
#fontcharset.monospaced.0=sun.io.CharToByteCp1252
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=00a0-f8ff
exclusion.dialog.italic.0=00a0-f8ff
exclusion.dialog.bold.0=00a0-f8ff
exclusion.dialog.bolditalic.0=00a0-f8ff
exclusion.dialoginput.plain.0=00a0-f8ff
exclusion.dialoginput.italic.0=00a0-f8ff
exclusion.dialoginput.bold.0=00a0-f8ff
exclusion.dialoginput.bolditalic.0=00a0-f8ff
exclusion.serif.plain.0=00a0-f8ff
exclusion.serif.italic.0=00a0-f8ff
exclusion.serif.bold.0=00a0-f8ff
exclusion.serif.bolditalic.0=00a0-f8ff
exclusion.sansserif.plain.0=00a0-f8ff
exclusion.sansserif.italic.0=00a0-f8ff
exclusion.sansserif.bold.0=00a0-f8ff
exclusion.sansserif.bolditalic.0=00a0-f8ff
exclusion.monospaced.italic.0=00a0-f8ff
exclusion.monospaced.bold.0=00a0-f8ff
exclusion.monospaced.bolditalic.0=00a0-f8ff
# charset for text input
# inputtextcharset=GB2312_CHARSET
保存後,一切問題就解決了!
這種方法也適用於任何相同的問題。
[題外話]這種錯誤SUN真的應該好好反省一下了,希望以後他們做的東西能夠測試更好一些。