I would like to move the mouse cursor from one position to another within a Jtextfield after a condition is satisfied.
I do not know what to use. Thank you
have you checked:
int offset;
//set int to whatever
jtextfieldname.setCaretPosition(offset);//use setCaretPosition() to move the caret to a specific offset in the jTextField
also i guess this would be of help: http://www.java-examples.com/get-current-caret-position-jtextfield-example
DavidKroukamp
Practically a Master Poster
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169
you mean like moving it to another jtextfield all components based elements in java should have a method
requestFocus(boolean temporary)
So to move the cursor to another component when condition is acomplished, you simply set it to true
boolean yourCondition = true;
yourJtextField.requestFocus(yourCondition);
hope it helps.
RicardoE
Junior Poster in Training
73 posts since Jan 2010
Reputation Points: 21
Solved Threads: 7