The method clears the listModel which defines the JList data, then the Addresses Vector is iterated through to pull out each address and get it's name into an array. This array is then sorted and once the sort is complete, I iterate through the array and add each name into the listModel - The end result is a brand new sorted listModel for the JList.
public void refresh(){
Address found;
this.listModel.clear();
int numItems = this.getAddressBookSize();
String[] a = new String[numItems];
for (int i=0;i<numItems;i++){
found = (Address)Addresses.get(i);
a[i] = found.getName();
}
/* attempt to sort the array */
Arrays.sort(a, String.CASE_INSENSITIVE_ORDER);
for (int i=0;i<numItems;i++) {
this.listModel.addElement(a[i]);
}
}
christo