The first and last index are not what you think they are. Here's what the javadoc says:
getFirstIndex()
Returns the index of the first row whose selection may have changed.
getLastIndex()
Returns the index of the last row whose selection may have changed.
So, since the selection of pear and orange changes at each click, and since pear is after orange in the list, getFirstIndex()
always returns Orange and getLastIndex()
always returns Pear.
If you want to compare the new selection with the last one, then keep the last selection in some member variable, and compare it with the new selection each time the selection changes, and getValueIsAdjusting()
returns false.