public ScreenField getComponentAfter ( ScreenField sfCurrent , int iSelectField ) { ScreenField m_ChildFocused = ( ScreenField ) sfCurrent ; if ( m_ChildFocused == null ) iSelectField = DBConstants . SELECT_FIRST_FIELD ; ScreenField sField = null ; ScreenField sPrevScreenField = null ; ScreenField sNextScreenField = null ; ScreenField sTargetScreenField = null ; ScreenField sLastFocusTarget = null ; ScreenField sFirstFocusTarget = null ; // Now survey the control to see which one is next for ( int iSField = 0 ; iSField < this . getSFieldCount ( ) ; iSField ++ ) { // This should only be called for Imaged GridScreens (Child windows would be deleted by now if Component) sField = this . getSField ( iSField ) ; if ( sField . isEnabled ( ) ) if ( sField . isFocusTarget ( ) ) { if ( sFirstFocusTarget == null ) sFirstFocusTarget = sField ; sLastFocusTarget = sField ; if ( sTargetScreenField != null ) if ( sNextScreenField == null ) sNextScreenField = sField ; if ( sField == m_ChildFocused ) sTargetScreenField = sField ; if ( sTargetScreenField == null ) sPrevScreenField = sField ; if ( sPrevScreenField != null ) if ( sTargetScreenField != null ) if ( sNextScreenField != null ) break ; // All targets found } if ( sField == m_ChildFocused ) sTargetScreenField = sField ; // In case focus on a control that doesn't accept focus } if ( sPrevScreenField == null ) sPrevScreenField = sLastFocusTarget ; // Last field if ( sNextScreenField == null ) sNextScreenField = sFirstFocusTarget ; // First field if ( iSelectField == DBConstants . SELECT_PREV_FIELD ) sNextScreenField = sPrevScreenField ; // Tab backwards if ( iSelectField == DBConstants . SELECT_FIRST_FIELD ) sNextScreenField = sFirstFocusTarget ; // First field sField = sNextScreenField ; return sField ; }
Returns the Component that should receive the focus after aComponent .