Pages

Thursday, July 15, 2010

How to Select All textfield/ password field Java

--start--
Sample code:

     int i = textfield.getText().length();
     textfield.setSelectionStart(0);
     textfield.setSelectionEnd(i);


Put this in the action or wherever you want it. Replace textfield variable to the name of your textfield. I'm not sure but this might work for JTextArea and JTextPane too.



--end---

0 comments:

Post a Comment