Here you can find the source of scrollComponentToEnd(JComponent c)
public static void scrollComponentToEnd(JComponent c)
//package com.java2s; //License from project: Open Source License import java.awt.Rectangle; import javax.swing.JComponent; public class Main { /**/*from w w w .j a v a2 s . c o m*/ * Scroll a component contained in a JScrollPane to its end */ public static void scrollComponentToEnd(JComponent c) { Rectangle r = c.getBounds(); scrollComponentTo(c, new Rectangle(0, r.height - 2, r.width, 2)); } /** * 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); } }