Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am creating a Log In page in which i am using a show password check box so that when i clicked that check box my password edit text change to Text data
(eg : '****' to '1234'), So Help me out for this.

Thanks & Regards
Posted
v2

Invalid.
A password is always masked during login. That is a common thing.
So please just drop the checkbox and let the password be a password.
 
Share this answer
 
i have done it using the following class :
C#
public class passwordTextField extends EditField
    {
        private final static String INIT_TEXT = "Enter Password";
        protected void paint(Graphics graphics)
        {
            String originalText = getText();
            String fakeText = originalText;
            if (originalText.equalsIgnoreCase(""))
            {
                fakeText = isFocus() ? originalText : INIT_TEXT;
            }
            else
            {
                if(LogInPage.flag == true)
                {
                    setText(originalText);
                }
                else
                {
                    fakeText = "";
                    for (int i=0 ; i<originalText.length();i++)
                    {
                        fakeText += '*';
                    }
                }
            }
            setText(fakeText);
            super.paint(graphics);
            setText(originalText);
        }
    }

and call this class in main screen as follows:
C#
passwordTextField password = new passwordTextField();
add(password);

and add change listener to showpassword check box
C#
 static boolean flag = false;
public void fieldChanged(Field field, int context)
{
        if(showPasswordCheckbox.getChecked() == true)
	{
	   flag = true;
	}
	else
	{
	   flag = false;
	}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900