Here you can find the source of scrollTo(JTextPane textPane, int position)
public static void scrollTo(JTextPane textPane, int position) throws BadLocationException
//package com.java2s; //License from project: Apache License import java.awt.Rectangle; import javax.swing.JTextPane; import javax.swing.text.BadLocationException; public class Main { /**//from w ww . j a v a 2s . c o m * Forces a portion of the document to become visible. */ public static void scrollTo(JTextPane textPane, int position) throws BadLocationException { Rectangle r = textPane.modelToView(position); if (r != null) { textPane.scrollRectToVisible(r); } } }