posted 20 years ago
Dear Ranchers:
I'm working on an assignment that uses a SortedMap implemented as a TreeMap to store a collection of objects. Part of the assignment is to use four buttons (first, previous, next and last) to retreive the objects from the collection. I have no problem with first and last but am having difficulty with both next and previous.
Here is the code for the ActionListener registered to the buttons with current being a Store object:
fillForm is just a method that extracts the variables in current and displays them in TextFields in the panel.
I know that at least part of my problem is with using Iterator. I expected the assignment for current with the next button ActionEvent to work. It does compile and run without any errors but does not result in any change to the value of current.
I know that my code for the previous button will not work (it does not compile) and I believe I understand correctly that this is because Iterator does not have a hasPrevious() or previous() method.
While ListIterator does have these methods, as far as I can figure out, ListIterator will not work with Maps, SortedMaps or TreeMaps.
I would appreciate any direction to resolve the next and previous problems.
TIA
Bob
[ February 26, 2004: Message edited by: Robert Davis ]