Here you can find the source of showPassword(JPasswordField pf, JCheckBox cb)
public static void showPassword(JPasswordField pf, JCheckBox cb)
//package com.java2s; //License from project: Open Source License import javax.swing.JCheckBox; import javax.swing.JPasswordField; public class Main { public static void showPassword(JPasswordField pf, JCheckBox cb) { if (cb.isSelected()) { pf.setEchoChar('\u0000'); } else {// w w w. jav a2 s .c o m pf.setEchoChar('*'); } } }