Is there any way to tell during the execution of the valueChanged method of a ListSelectionListener whether the user clicked the JList or whether setSelectedIndex was called by some other code?
Is there any way to tell during the execution of the valueChanged method of
Share
AFAIK, no. But if the goal is to only execute something if the selection comes from the user, you may set a flag before selecting an index in the code to signal that the selection doesn’t come from the user, or remove the listener and add it afterwards: