Java tutorial
//package com.java2s; //License from project: Open Source License import java.awt.Component; import javax.swing.JTabbedPane; public class Main { public static JTabbedPane getJTabbedPaneAncestor(Component c) { while (c != null) { if (c instanceof JTabbedPane) { return (JTabbedPane) c; } c = c.getParent(); } return null; } }