java - Display/disappear default text in TextField when user enters data/erase the text -
i trying make registration form , trying display default text in text fields, simple meaning below image. trying , until user enters data field example there field called "first name". when user selects field "first name" text disappears , user can type first name. if user doesn't type anything, text should display again in text field.
i tried using focus listener, couldn't work because method if user types data field , go next field , text of previous field gets deleted , default text gets displayed.
here have done :-
txtfirstname.addfocuslistener(new focuslistener() { public void focusgained(focusevent e) { txtfirstname.settext(""); } public void focuslost(focusevent e) { txtfirstname.settext("first name"); } });
thank time.
what trying , until user enters data field example there field called "first name". when user selects field "first name" text disappears , user can type first name. if user doesn't type anything, text should display again in text field.
i think looking prompt, see
text prompt @camickr
another ideas how create prompt jtextfield
Comments
Post a Comment