Here you can find the source of setViewportBorder(JScrollPane scrollPane, int vertical, int horizontal)
public static void setViewportBorder(JScrollPane scrollPane, int vertical, int horizontal)
//package com.java2s; //License from project: Open Source License import javax.swing.BorderFactory; import javax.swing.JScrollPane; public class Main { public static void setViewportBorder(JScrollPane scrollPane, int vertical, int horizontal) { scrollPane.setViewportBorder(BorderFactory.createMatteBorder(vertical, horizontal, vertical, horizontal, scrollPane.getViewport().getView().getBackground())); }/*from w w w. j a v a 2 s . c o m*/ }