List of usage examples for java.awt Container isAncestorOf
public boolean isAncestorOf(Component c)
From source file:StackLayout.java
/** * Set the currently displayed component. If passed null for the component, * all contained components will be made invisible (sliding windows do this) * @param c Component to show//from w w w .ja v a 2 s. com * @param parent Parent container */ public void showComponent(Component c, Container parent) { Component comp = getVisibleComponent(); if (comp != c) { if (!parent.isAncestorOf(c) && c != null) { parent.add(c); } synchronized (parent.getTreeLock()) { if (comp != null) { comp.setVisible(false); } visibleComp = new WeakReference<Component>(c); if (c != null) { c.setVisible(true); } // trigger re-layout if (c instanceof JComponent) { ((JComponent) c).revalidate(); } else { parent.validate(); //XXX revalidate should work! } } } }