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

Edited 4 Years Ago by DavidKroukamp: n/a

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.

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.

No I don't want to move the cursor to another component, but within the same JTexfield.

thanks for the reply

This question has already been answered. Start a new discussion instead.