Java tutorial
//package com.java2s; import java.awt.*; public class Main { public static boolean isComponentVisible(Component comp) { if (!comp.isVisible() && !isRootComponent(comp)) { return false; } Component parent = comp.getParent(); return parent == null || isComponentVisible(parent); } public static boolean isRootComponent(Component root) { Container parent = root.getParent(); return parent == null; } }