@Override public void caretUpdate(CaretEvent e) { if (getFollowCaret()) { int line = textArea.getCaretLineNumber(); float percent = line / (float)(textArea.getLineCount()-1); textArea.computeVisibleRect(visibleRect); caretLineY = (int)(visibleRect.height*percent); if (caretLineY!=lastLineY) { repaint(0,lastLineY, getWidth(), 2); // Erase old position repaint(0,caretLineY, getWidth(), 2); lastLineY = caretLineY; } } }
public void caretUpdate(CaretEvent e) { if (getFollowCaret()) { int line = textArea.getCaretLineNumber(); float percent = line / ((float)textArea.getLineCount()); textArea.computeVisibleRect(visibleRect); caretLineY = (int)(visibleRect.height*percent); if (caretLineY!=lastLineY) { repaint(0,lastLineY, getWidth(), 2); // Erase old position repaint(0,caretLineY, getWidth(), 2); lastLineY = caretLineY; } } }
@Override public void caretUpdate(CaretEvent e) { if (getFollowCaret()) { int line = textArea.getCaretLineNumber(); float percent = line / (float)(textArea.getLineCount()-1); textArea.computeVisibleRect(visibleRect); caretLineY = (int)(visibleRect.height*percent); if (caretLineY!=lastLineY) { repaint(0,lastLineY, getWidth(), 2); // Erase old position repaint(0,caretLineY, getWidth(), 2); lastLineY = caretLineY; } } }