Hi I am almost done my intro to
Java course assignments but am having a hard time trying to figure out the following question:
Create a password entry application that accepts the password but only shows the number of characters entered so far. Then, add a button that allows the user to toggle between seeing the password and seeing the number of characters in the same password field.
As of right now I am using a JTextField instead of JPasswordField because I'm not quite sure of how to display contents of a password field. The problem I am having right now is trying to display the number of characters that have been entered into the textbox. When I run the program, the number of characters typed only goes upto 2. Here is my code:
Here is my
test class:
I know the problem is that every time a key is typed, the
String is redefined as the current text in the box, this is why I can't get anymore than 2 characters to show up. I just don't know how to resolve the problem. Thanks for reading this.