Java examples for Swing:JComponent
get Viewport Ancestor from Component
//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; }//from w w w . ja v a2s . c o m } return null; } }