FileDocCategorySizeDatePackage
CallTrack.javaAPI DocExample844Sun Feb 29 12:51:46 GMT 2004None

CallTrack

public class CallTrack extends Object
Code Fragmment showing how to insert in two lists (an ArrayList and an AWT List) in sorted order, using a simple linear search of the ArrayList to find the object (or end of list) before which to insert the new user.

Fields Summary
protected List
usrList
The list of Person objects.
protected List
visList
The scrolling list
Constructors Summary
Methods Summary
protected voidadd(Person p)
Add one (new) Person to the list, keeping the list sorted.


	            
	    
		String lastName = p.getLastName();
		int i;
		for (i=0; i<usrList.size(); i++)
			if (lastName.compareTo(((Person)(usrList.get(i))).getLastName()) <= 0)
				break;
		usrList.add(i, p);
		visList.add(p.getName(), i);
		visList.select(i);      // ensure current