static void removeFromParent(Component c) { if (c != null) swing { Container cc = c.getParent(); if (cc != null) cc.remove(c); } }