3
Contributors
4
Replies
6
Views
5 Years
Discussion Span
Last Post by jkembo
2

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 by DavidKroukamp: n/a

-1

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.

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.