In my GUI I have a JList showing strings
I would like to be able to check if the user has clicked inside the JList but no item has been selected.
At the moment, if my JList contains, say, 3 strings and the user clicks on any of them then I can get the selected item index and value (selected string).
If the user clicks inside the JLIst but not on any of the 3 string I would like to be able to avoid the last of the 3 strings to be automatically selected.

I also have a JPopUpMenu bound to the JList.
If the used right-click anywhere inside the JList then the JPopUpMenu becomes visible and its items are selectable. This behavior makes sense if the user has selected one of the JList items.
I would like to prevent the JPopUpMenu from appearing if the user has right-clicked inside the JList but has selected no item.

Thank you in advance for your help
Regards