求指教:
在编写记事本程序时,怎么获得文本区的鼠标所在行号和列号???

解决方案 »

  1.   

    看这三个方法
    getCaretPosition
    getLineOfOffset
    getLineStartOffset
      

  2.   

    int caret = editor.getCaretPosition();
    int line  = editor. getLineOfOffset(caret); // 从 0 开始
    int column  = caret - editor.getLineStartOffset(line); // 从 0 开始
    String text = String.format("Caret:[%d,%d]", line + 1, column +1);