如何得到文本域中键盘光标的坐标?

jayli426 2008-05-08 11:26:20
我想做一个能实现jcreator,jbuilder那样ide的的intellisense的功能(比如说在编辑代码时敲入import空格,ide就能自动列出处于所有类路径下的类名和包名供开发者选择),我的想法是用一个文本域供输入代码,该文本域监听文本内容的改变,如果发现开发者输入“import ”这样的关键字时,用一个JList组件在关键字的坐标处呈现所有类路径下的类名和包名供他选择。
...全文
76 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jayli426 2008-05-08
  • 打赏
  • 举报
回复
这个是光标的位置,不是光标的坐标吧??

请大虾继续指导啊
Inhibitory 2008-05-08
  • 打赏
  • 举报
回复
public int getCaretPosition()

Returns the position of the text insertion caret. The caret position is constrained to be between 0 and the last character of the text, inclusive. If the text or caret have not been set, the default caret position is 0.

Returns:
the position of the text insertion caret

62,616

社区成员

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

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