Here you can find the source of findScrollPane(Component component)
private static JScrollPane findScrollPane(Component component)
//package com.java2s; //License from project: Open Source License import java.awt.Component; import java.awt.Container; import javax.swing.JScrollPane; public class Main { private static JScrollPane findScrollPane(Component component) { if (component instanceof JScrollPane) return (JScrollPane) component; if (component instanceof Container) { Container c = (Container) component; for (int i = 0; i < c.getComponentCount(); i++) { JScrollPane result = findScrollPane(c.getComponent(i)); if (result != null) return result; }//from w w w. j a v a 2s . co m } return null; } }