Here you can find the source of scrollComponentTo(JComponent c, Rectangle r)
public static void scrollComponentTo(JComponent c, Rectangle r)
//package com.java2s; //License from project: Open Source License import java.awt.Rectangle; import javax.swing.JComponent; public class Main { /**/* w w w . ja v a 2s. co m*/ * Scroll a component contained in a JScrollPane to its end */ public static void scrollComponentTo(JComponent c, Rectangle r) { int extraHeight = 40; // 2*r.height ; Rectangle rr = new Rectangle(r.x, r.y - extraHeight, r.width, 2 * extraHeight + r.height); Rectangle rrr = rr.intersection(c.getBounds()); //System.out.println( "rr=" + rr + ", rrr=" + rrr + ", bounds=" + c.getBounds() ) ; if (rrr.height > 0) c.scrollRectToVisible(rrr); } }