如何将 CaretEvent.getDot() 转换为直角坐标?

how to convert CaretEvent.getDot() to rectangular coordinates?

实际上我正在尝试显示用户当前在 JTextArea 中键入的行号和列号。我的问题是如何将 CaretEvent.getDot() 转换为直角坐标以便实现此目的?或者还有其他方法吗?

也许您正在寻找使用 JTextArea 方法,public Rectangle modelToView(int location)。实际上,这是 JTextArea 的父级 class、JTextComponent 中的一个方法,可以帮助将文档中的 int 位置转换为 GUI 本身中相对于文本组件的当前矩形位置。

i am trying to display the line number and coloumn number the user is currently typing in a JTextArea

查看 Text Utilities。它提供了如下方法:

  1. getColumnAtCaret(...)
  2. getLineAtCaret(...)