protected FocusListener createFocusListener ( ) { return new FocusAdapter ( ) { @ Override public void focusLost ( FocusEvent e ) { String textFieldValue = getKeyComponentText ( ) ; boolean empty = "" . equals ( textFieldValue . trim ( ) ) ; Object ref = LookupBinding . this . getValue ( ) ; if ( evaluateFocusLost ( e ) ) { // Revert if value isn't empty if ( revertValueOnFocusLost ( ) ) { if ( empty ) getValueModel ( ) . setValue ( null ) ; else valueModelChanged ( LookupBinding . super . getValue ( ) ) ; } // Create new referable if value isn't empty else { if ( empty && ( ref != null ) ) getValueModel ( ) . setValue ( null ) ; else if ( ! empty && ( ( ref == null ) || ! textFieldValue . equals ( getObjectLabel ( ref ) ) ) ) getValueModel ( ) . setValue ( createFilterFromString ( textFieldValue ) ) ; } } } } ; }
Create a focus listener to attach to the textComponent and dataEditorButton that will decide what happens with the changed value . Here a revert can be done if no value is selected or a new value can be created as needed .