In my program, it seems that sometimes the addElement(Object element) method in the DefaultListModel of my JTable causes a ListSelectionEvent. That seems strange to me because ListSelectionEvent objects are usually caused by changes in the selection of a JTable. Just adding elements to the end of a DefaultListModel should not change the selection(s) of a JTable, I think.
Are there any situations in which adding an element to the end of a DefaultListModel would cause a ListSelectionEvent? What kind of situation? Why? (there are some things in life that don't have a reason, but if there is a reason you can think of, please tell me) What is a good way to prevent a ListSelectionEvent?
Start up the program and click the words "click me". That will generate a ListSelectionEvent. Then, click the button "Take Out". That will generate another ListSelectionEvent, because the selected item is deleted. Then, click the "Append" button. That generates another ListSelectionEvent, but I don't know why. Before the button is clicked, and after the button is clicked, nothing is selected, so there should be no change in the selection which would generate an event.
Joined: Oct 12, 2005
In my original message I made a mistake. It's not JTable, it's JList.