I'm writing a contact book application in Java using the swing and awt libraries. The Application consists of a JList which uses a TreeSet as an abstractListModel.
The TreeSet is for a class called Contact, which has private comparator class that sorts contacts based on their first name. the private boolean equals(Object o)
method returns true if the Contact has the same mobileNumber as that of O (after casting, of course).
I want to add a search functionality into this application. I've made a search JTextField and added a keyListener and what I want to do is that after each key is pressed, the list displays a narrow down set of results which contains the search terms. Is there a method for this in TreeSet or any other Collection? I want it to be similar to what you have in the Music Application in iPods, where when you type the letter 'f', for example, it lists all the songs that contain the letter F but it's only when you type 'fifty cent' that the songs by the singer you want appear.
Thanks for your help.