J
Jack Crow
I have:
JList nameList;
DefaultListModel nameListModel; (with SINGLE_SELECTION)
I would like to add a listener to individual JList items (as they are
added to the JList, or after) so that I can bring up a popupmenu on
RightClick of an individual selected JList item (only when RightClick
is physically on the currently selected item "field"/row).
Perhaps the elements are considered part of the ListModel, but that
doesn't change the problem.
The elements are added using addElement(String newName); so how do I
attach a MouseListener to that? I am avoiding adding a MouseListener
to the JList then doing some math via counting the number of elements
and figuring out their individual bounds and then counting down...to
figure out if the RightClick is "within the bounds" of the "currently
selected item", because that seems a rather brutish solution.
JList nameList;
DefaultListModel nameListModel; (with SINGLE_SELECTION)
I would like to add a listener to individual JList items (as they are
added to the JList, or after) so that I can bring up a popupmenu on
RightClick of an individual selected JList item (only when RightClick
is physically on the currently selected item "field"/row).
Perhaps the elements are considered part of the ListModel, but that
doesn't change the problem.
The elements are added using addElement(String newName); so how do I
attach a MouseListener to that? I am avoiding adding a MouseListener
to the JList then doing some math via counting the number of elements
and figuring out their individual bounds and then counting down...to
figure out if the RightClick is "within the bounds" of the "currently
selected item", because that seems a rather brutish solution.