I was searching on web regarding this but could not find any relevant answer. Actually, my JList currently appends new row at the bottom of list. What my problem case needs is I want to add or prepend new row added to my JList model (at the top). How can I achieve this?
I was searching on web regarding this but could not find any relevant answer.
Share
Had you visited the java docs, you would have known of a certain method
add(int index, Object element)for thelistModelwhich in case should be used to insert the element at the index you desire.EXAMPLE: