Java JScrollPane Create getScrollPane(Component innerComponent)

Here you can find the source of getScrollPane(Component innerComponent)

Description

Gets the scroll pane around the component.

License

Open Source License

Parameter

Parameter Description
innerComponent a parameter

Return

the scroll pane. Null if the component is not in any JScrollPane.

Declaration

public static Component getScrollPane(Component innerComponent) 

Method Source Code

//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;
        }
    }
}

Related

  1. getScrollPane( Component innerComponent)
  2. getScrollPane(BasicComboPopup popup)
  3. getScrollPane(Component component)
  4. getScrollPane(Component component)
  5. getScrollPane(final Component component)
  6. getScrollPaneAncestor(Component c)
  7. getScrollPaneViewComponent(JComponent component)
  8. makeScrollable(JComponent c)