public int valueToIndex ( Object value ) { if ( value != null ) if ( ! ( value instanceof String ) ) value = value . toString ( ) ; if ( ( m_record != null ) && ( m_strIndexValue != null ) ) { try { FieldTable table = m_record . getTable ( ) ; for ( int iIndex = 0 ; ; iIndex ++ ) { if ( table . get ( iIndex ) == null ) // I use get, so the index matches the index of JComboBox break ; FieldInfo field = m_record . getField ( m_strIndexValue ) ; if ( field == null ) field = m_record . getField ( 0 ) ; String strValue = field . getString ( ) ; if ( ( strValue != null ) && ( strValue . length ( ) > 0 ) ) if ( strValue . equals ( value ) ) return iIndex + 1 ; } } catch ( Exception ex ) { ex . printStackTrace ( ) ; } } else { this . setSelectedItem ( value ) ; if ( this . getSelectedIndex ( ) != - 1 ) return this . getSelectedIndex ( ) ; } return 0 ; }
Convert this value to a selection index .