问题
I try to run javafx
Password Field Demo on my desktop

enviroment:
win7 64 cmd->chcp:GBK
java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
jdk version switch to "1.8.0_191
" and "1.8.0_131
",the same result.
then I tried to run the Demo on my colleague's desktop
win7 64 cmd->chcp:UTF-8
java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

But on my notebook
win8 64 cmd->chcp:GBK
java -version
java version "1.8.0_191"/"1.8.0_161"/"1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
It shows normally with BULLET
回答1:
The very first line in your version prints the problem is clear:
cmd->chcp:GBK
vs cmd->chcp:UTF-8
On your Notebook and Desktop PC you have the GBK character encoding (cmd->chcp:GBK
) but your collegue's PC uses UTF-8 (cmd->chcp:UTF-8
). As your code therefore also is likely written with the GBK encoding, your colleague's PC tries to interpret the character in UTF-8 but the UTF-8 character space doensn't hold the bullet symbol (if any character at all) there.
I'd suggest you to convert your code to Unicode and use \u2022
(which is the unicode encoding for the bullet) as the symbol rather than add it typing it or setting it hardcoded in any other way.
来源:https://stackoverflow.com/questions/53368664/javafx-passwordfield-echo-char-different-on-different-computer