I have some text component (particularly it JEditorPane), and need as response to certain event to make some line in the text component visible – i.e. scroll to it if that necessary. How to do this with Swing?
I find setCaretPosition but it not always good. If caret was already at position set for it new, it not make it visible again.
from tutorials How to Use Editor Panes and Text Panes and How to Use Scroll Panes you can get JViewPort that’s determine visible Rectangle
example:
and you can move with that by using JScrollPane#scrollRectToVisible(Rectangle aRect)