Matt Gerrans
Posts: 1153
Nickname: matt
Registered: Feb, 2002
|
|
Re: Need Help wit JList Please
|
Posted: Nov 7, 2003 12:57 PM
|
|
I assume dlm is a DefaultListModel object. Yes, you need to go through your list and add each item to the list model. Why are you using a home-made list instead of an ArrayList or LinkedList? If it is for a homework assignment, have you been asked to also provide an iterator? It might be that will be the next assignment, so in the mean time, you could just step through your list of items, adding each to the model.
If the homework assignment was to make a full-fledge implementation of a List, then your list should implement the java.utils.List interface, which would include the method iterator() (why not getIterator()? I don't know).
This means, of course that you also need to create a companion class that implements the Iterator interface. Your iterator class would likely be an inner class of your collection class.
Then later on in the course, you might focus on making the whole thing thread-safe.
Later still, you'll throw the whole thing out, because the built-in collections are going to be a lot more effient, complete and tested (by millions of users!).
|
|