So, what I want, is for when a JList
item is selected, for another bit of code to run. But my question is, how do I implement MouseListeners
for specif
If you want something to happen when the selection changes, you don't want a MouseListener, but a ListSelectionListener
. Not only is it the right abstraction, but remember that the selection can change without using the mouse. Most computer have a keyboard these days.
How to use one is described in the Swing tutorial.
Inside your listener, get the element that is selected, and act accordingly.