JPassword
フィールドに値を設定する必要があります。しかし、それは方法がないように見えるsetPassword (char [])
JPasswordフィールドに値を設定するにはどうすればよいですか?
これの唯一の方法はsetText
です。しかし、私はフィードをする必要があります
getText
は廃止予定ですので、setText
も廃止予定です。ここで
setText
が起こるん
When calling getText you get a String (immutable object) that may not be changed (except reflection) and so the password stays in the memory until garbage collected
String
をフィードし、それはメモリにとどまります。
setText
はなぜ非推奨ですか?
setPassword (char [])
メソッドがないのはなぜですか?
ここでは、フィールドの 'PlainDocument'とchar配列を使用する例を示します(ドキュメントが読み込まれるとクリアすることができます):http://stackoverflow.com/questions/26975275/fill-a-jpasswordfield -programmatically-without-string-objectを作成する – Berger
それはうまくいくようです。 – john