Here you can find the source of getJTabbedPaneAncestor(Component c)
public static JTabbedPane getJTabbedPaneAncestor(Component c)
//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; }//w ww. j a va 2s.c om c = c.getParent(); } return null; } }