protected void moveRightToLeft() {
        Object[] chosenSelectedValues = chosenList.getSelectedValues();
        int nChosenSelected = chosenSelectedValues.length;
        int[] chosenSelected = new int[nChosenSelected];

        if (nChosenSelected == 0) {
            return; // Nothing to move
        }

        // Get our current selection
        int[] currentSelected = helperList.getSelectedIndices();
        int nCurrentSelected = currentSelected.length;

        // Fill the chosenSelected array with the indices of the selected chosen
        // items
        for (int i = 0; i < nChosenSelected; i++) {
            chosenSelected[i] = indexOf(chosenSelectedValues[i]);
        }

        // Construct the new selected indices. Loop through the current list
        // and compare to the head of the chosen list. If not equal, then add
        // to the new list. If equal, skip it and bump the head pointer on the
        // chosen list.

        int newSelection[] = new int[nCurrentSelected - nChosenSelected];
        int newSelPos = 0;
        int chosenPos = 0;

        for (int i = 0; i < nCurrentSelected; i++) {
            int currentIdx = currentSelected[i];
            if (chosenPos < nChosenSelected && currentIdx == chosenSelected[chosenPos]) {
                chosenPos += 1;
            } else {
                newSelection[newSelPos++] = currentIdx;
            }
        }

        // Install the new selection
        helperList.setSelectedIndices(newSelection);
        update();
    }
protected void moveRightToLeft ( ) { Object [ ] chosenSelectedValues = chosenList . getSelectedValues ( ) ; int nChosenSelected = chosenSelectedValues . length ; int [ ] chosenSelected = new int [ nChosenSelected ] ; if ( nChosenSelected == 0 ) { return ; } int [ ] currentSelected = helperList . getSelectedIndices ( ) ; int nCurrentSelected = currentSelected . length ; for ( int i = 0 ; i < nChosenSelected ; i ++ ) { chosenSelected [ i ] = indexOf ( chosenSelectedValues [ i ] ) ; } int newSelection [ ] = new int [ nCurrentSelected - nChosenSelected ] ; int newSelPos = 0 ; int chosenPos = 0 ; for ( int i = 0 ; i < nCurrentSelected ; i ++ ) { int currentIdx = currentSelected [ i ] ; if ( chosenPos < nChosenSelected && currentIdx == chosenSelected [ chosenPos ] ) { chosenPos += 1 ; } else { newSelection [ newSelPos ++ ] = currentIdx ; } } helperList . setSelectedIndices ( newSelection ) ; update ( ) ; }
Move the selected items in the chosen list to the source list. I.e.,
remove them from our selection model.