在一个TextArae中如何得到当前光标的坐标!

cw550284 2008-04-08 06:11:03
是在java中啊啊
...全文
73 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangshikang_it 2008-04-18
  • 打赏
  • 举报
回复
可以用鼠标事件
cw550284 2008-04-16
  • 打赏
  • 举报
回复
可是怎么就返回一个值啊!!
光标的位置应该包含(x,y)啊
guofei_gf 2008-04-11
  • 打赏
  • 举报
回复

TextArea text = new JTextArea();
int position = text.getCaretPosition();
position 就是当前光标的位置
cw550284 2008-04-11
  • 打赏
  • 举报
回复
可以给具体点吗????
J_Factory 2008-04-09
  • 打赏
  • 举报
回复
楼上的想法不错
Inhibitory 2008-04-08
  • 打赏
  • 举报
回复
javax.swing.text.JTextComponent.getCaretPosition()

public int getCaretPosition()
Returns the position of the text insertion caret for the text component.

Returns:
the position of the text insertion caret for the text component >= 0

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧