static void removeAndValidate(final Component c) { if (c != null) swing { Container cc = c.getParent(); if (cc != null) { cc.remove(c); cc.revalidate(); cc.repaint(); // bugs without this } } }