public Component getComponentByName ( String strName , Container parent ) { for ( int i = 0 ; i < parent . getComponentCount ( ) ; i ++ ) { Component component = parent . getComponent ( i ) ; if ( strName . equals ( component . getName ( ) ) ) return component ; if ( component instanceof Container ) { component = this . getComponentByName ( strName , ( Container ) component ) ; if ( component != null ) return component ; } } return null ; // Not found }
Get the sub - component with this name .