在 JTextField 中查找光标文本位置 [英] Finding the cursor text position in JTextField
本文介绍了在 JTextField 中查找光标文本位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法返回字符在JTextField中的位置.我的意思是如果我有一个 JTextField其中有一些价值.例如,该字段包含值ABCDEFJ.用户决定将光标放在字符C"以输入新值.有没有获取方法他进入新角色的位置.在这个例子中,那将返回 3.
Is there a method to return the position of the character in the JTextField. What I mean by that is if I have a JTextField with some values in it. For example, the field contains value ABCDEFJ. The user decides to put the cursor right after the character 'C' to enter a new value. Is there a method to get position where he enters the new character. In this example, that would return a 3.
推荐答案
JTextField.getCaretPosition()
JTextField.setCaretPosition(int pos)
这篇关于在 JTextField 中查找光标文本位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文