JComponent () { int count = myContentComponentPanel.getComponentCount(); if (count == 0) return null; Component component = myContentComponentPanel.getComponent(0); return component == myMessagePanel ? null : (JComponent)component; }