Is your problem that you don't want the contents to be selected?
You can probably add a listener and have it turn off the selection.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Is your problem that you don't want the contents to be selected?
You can probably add a listener and have it turn off the selection.
If you don't understand my answer, don't ignore it, ask a question.
john123 (March 24th, 2012)
Yes,when i accidentally double click on it ,i dont want contents to be selected ,but that doesn't mean that i am not using
manual or desired mouse focus selection ,so its not like i can turn off the focus.
Do you mean i can add a mouse double click listener ,or some other kind?
What is the difference between an accidental selection and a desired selection?
If you don't understand my answer, don't ignore it, ask a question.
john123 (March 24th, 2012)
Accidental is when i double click accidentally so the focus is in the whole content and that annoys my desired mouse selection
that trys to select only few numbers in the field.
I think you can unselect when a selection has been made. See the caretlistener and use the caret setting methods.
If you don't understand my answer, don't ignore it, ask a question.
john123 (March 24th, 2012)
Yess! I Done it!
I just want to brag a little ,this is big thing for a n00b
I use a mouse listener and it works perfectly:
textField.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.getClickCount() == 1 ) { d = textField.getCaret().getMark(); } if (e.getClickCount() == 2 ) { textField.setCaretPosition(d); } } });
Last edited by john123; March 25th, 2012 at 07:02 AM.