(Omit source code)
// construct a field 10 characters wide JPasswordField pwf=new JPasswordField(10); pwf.setEchoChar('#"); add(pwf);