protected void update() {
        int sz = dataModel.getSize();
        int[] selected = helperList.getSelectedIndices();
        ArrayList sourceItems = new ArrayList(sz);
        ArrayList chosenItems = new ArrayList(selected.length);

        // Start with the source items filled from our data model
        for (int i = 0; i < sz; i++) {
            sourceItems.add(dataModel.getElementAt(i));
        }

        // Now move the selected items to the chosen list
        for (int i = selected.length - 1; i >= 0; i--) {
            chosenItems.add(sourceItems.remove(selected[i]));
        }

        Collections.reverse(chosenItems); // We built it backwards

        // Now install the two new lists
        sourceList.setListData(sourceItems.toArray());
        chosenList.setListData(chosenItems.toArray());
    }
protected void update ( ) { int sz = dataModel . getSize ( ) ; int [ ] selected = helperList . getSelectedIndices ( ) ; ArrayList sourceItems = new ArrayList ( sz ) ; ArrayList chosenItems = new ArrayList ( selected . length ) ; for ( int i = 0 ; i < sz ; i ++ ) { sourceItems . add ( dataModel . getElementAt ( i ) ) ; } for ( int i = selected . length - 1 ; i >= 0 ; i -- ) { chosenItems . add ( sourceItems . remove ( selected [ i ] ) ) ; } Collections . reverse ( chosenItems ) ; sourceList . setListData ( sourceItems . toArray ( ) ) ; chosenList . setListData ( chosenItems . toArray ( ) ) ; }
Update the two lists based on the current selection indices.