It is intended to be source-compatible with java.awt.TextField's echoCharIsSet(), getEchoChar(), and setEchoChar() methods. This functionality has been removed from JTextField because there are potentially many ways to implement a password field. Factoring the functionality into a separate class makes it possible to provide different inplementations as separate subclasses of JTextField. It also makes it easier to safely change the UI for the JTextField without affecting password entries.
setEchoChar() sets the character that will be displayed as keyboard input is received from the user. This is largely a suggestion to the view, because the actual view that gets installed can use whatever graphic techniques it desires to represent the field. Setting a value of 0 unsets the echo character.
requestFocus() allows the programmer to ask that the input cursor be pre-positioned in a specific component.
The example creates both a JPasswordField and a JTextField, and then causes them both to share the same "document model". Whenever a change is made in one, the change is also reflected in the other. But, the JPasswordField component only reveals the length of the input.
[Source: Topley, pp661-663]