Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.awt.Component;

import javax.swing.JScrollPane;

public class Main {
    /**
     * Get the {@link JScrollPane} that surrounds the given component.
     * @return The desired {@link JScrollPane} or <code>null</code> if no {@link JScrollPane} could be found.
     */
    public static JScrollPane getSurroundingScrollPane(Component comp) {
        JScrollPane fScrollPane = null;
        while (comp != null) {
            comp = comp.getParent();
            if (comp instanceof JScrollPane) {
                fScrollPane = (JScrollPane) comp;
                break;
            }
        }
        return fScrollPane;
    }
}