2

我需要填充JPassword字段。但是看起来没有方法setPassword (char [])

唯一的方法是setText. 但是我需要喂一个String

由于getText已弃用,所以我认为setText也将被弃用。

这是stackoverflow上答案的摘录

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

当我setText. 我喂一个String,它留在记忆中。为什么不setText被弃用?为什么没有setPassword (char [])方法?

4

1 回答 1

1

为什么没有 setPassword (char []) 方法?

最后插入字符串还是字符数组都是一样的。

...所以我认为 setText 也将被弃用。

不,不会的。通常用户会输入密码。如果您将密码存储在某个地方,则需要对其进行解密并将其插入此字段,然后才能发送它们。

于 2016-07-04T15:34:46.973 回答