Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import javax.swing.*;
import java.awt.*;

public class Main {
    public static JViewport getViewportAncestor(Component c) {
        for (Container p = c.getParent(); p != null; p = p.getParent()) {
            if (p instanceof JViewport) {
                return (JViewport) p;
            }
        }
        return null;
    }
}