JavaFX PasswordField echo char different on Different computer

橙三吉。 提交于 2019-12-24 21:03:52

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!