Here you can find the source of getScrollPane(Component innerComponent)
Parameter | Description |
---|---|
innerComponent | a parameter |
public static Component getScrollPane(Component innerComponent)
//package com.java2s; import javax.swing.*; import java.awt.*; public class Main { /**/* ww w. java 2s. c o m*/ * Gets the scroll pane around the component. * * @param innerComponent * @return the scroll pane. Null if the component is not in any JScrollPane. */ public static Component getScrollPane(Component innerComponent) { Component component = innerComponent; if (innerComponent instanceof JScrollPane) { return innerComponent; } if (component.getParent() != null && component.getParent().getParent() != null && component.getParent().getParent() instanceof JScrollPane) { component = component.getParent().getParent(); return component; } else { return null; } } }