Swing\'s JPasswordField has the getPassword() method that returns a char array. My understanding of this is that the array can be zeroed immediately after use so that you do
This works for me and helps you to build a Stringified password:
String passText = new String(passField.getPassword());