# Substance client properties

View all API methods.

View all client properties.

Client property name | SubstanceLookAndFeel.PASSWORD_ECHO_PER_CHAR

Description | Client property name for specifying the number of echo characters for each password character. The value should be an instance of `Integer`, otherwise will be ignored. This property can be set either on a specific `JPasswordField` or globally on `UIManager`.

See also |

Sample code | `import java.awt.BorderLayout; import java.awt.FlowLayout; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener;
import org.jvnet.substance.SubstanceLookAndFeel;
import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel;
/**
* Test application that shows the use of the
* {@link SubstanceLookAndFeel#PASSWORD_ECHO_PER_CHAR} client property.
*
* @author Kirill Grouchnikov
* @see SubstanceLookAndFeel#PASSWORD_ECHO_PER_CHAR
*/
public class PasswordEchoPerChar extends JFrame {
/**
* Creates the main frame for <code>this</code> sample.
*/
public PasswordEchoPerChar() {
super("Password echo per char");
this.setLayout(new BorderLayout());
final JPanel panel = new JPanel(new FlowLayout());
this.add(panel, BorderLayout.CENTER);
final JPasswordField jpf = new JPasswordField("sample");
jpf.setColumns(20);
panel.add(jpf);
JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));
final JSpinner countSpinner = new JSpinner();
SpinnerNumberModel model = new SpinnerNumberModel(1, 1, 5, 1);
countSpinner.setModel(model);
countSpinner.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
// set the amount of echo per character based on the current
// value in the spinner
jpf.putClientProperty(
SubstanceLookAndFeel.PASSWORD_ECHO_PER_CHAR,
countSpinner.getValue());
jpf.repaint();
}
});
controls.add(new JLabel("Echo per char"));
controls.add(countSpinner);
this.add(controls, BorderLayout.SOUTH);
this.setSize(400, 200);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
/**
* The main method for <code>this</code> sample. The arguments are
* ignored.
*
* @param args
* Ignored.
* @throws Exception
* If some exception occured. Note that there is no special
* treatment of exception conditions in <code>this</code>
* sample code.
*/
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel());
JFrame.setDefaultLookAndFeelDecorated(true);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new PasswordEchoPerChar().setVisible(true);
}
});
}
}`

The screenshot below shows application frame with password field that has the default setting of 1 echo character (this property is not set):

The screenshot below shows application frame with password field with this property set to 2 echo characters: