Here you can find the source of defaultGetAutoscrollInsets(JComponent comp)
public static Insets defaultGetAutoscrollInsets(JComponent comp)
//package com.java2s; /*/*from w w w. j a va 2 s .co m*/ * Copyright appNativa Inc. All Rights Reserved. * * This file is part of the Real-time Application Rendering Engine (RARE). * * RARE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ import java.awt.Dimension; import java.awt.Insets; import java.awt.Rectangle; import javax.swing.JComponent; public class Main { final static int AUTOSCROLL_INSET_SIZE = 20; public static Insets defaultGetAutoscrollInsets(JComponent comp) { Rectangle visible = comp.getVisibleRect(); Dimension size = comp.getSize(); int top = 0, left = 0, bottom = 0, right = 0; if (visible.y > 0) { top = visible.y + AUTOSCROLL_INSET_SIZE; } if (visible.x > 0) { left = visible.x + AUTOSCROLL_INSET_SIZE; } if (visible.y + visible.height < size.height) { bottom = size.height - visible.y - visible.height + AUTOSCROLL_INSET_SIZE; } if (visible.x + visible.width < size.width) { right = size.width - visible.x - visible.width + AUTOSCROLL_INSET_SIZE; } return new Insets(top, left, bottom, right); } }