I have a Java Swing Jlist, and I know how to process a left-click and right-lick on a "selected item", but my question here is : If item 1 is currently selected, but when I right click on item 3, how to get that item's info/identity ? For example, in the following image, as you can see,
Salsa_2015_03_01_1 is selected, but if now I right mouse click on Salsa_2015_03_01_3, how to get that item's info in the following sample code :
list.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
String File_Path=File_Map.get(list.getSelectedValue().toString()).getAbsolutePath();
if (SwingUtilities.isLeftMouseButton(e))
{
// Out("Left-Click");
}
else if (SwingUtilities.isRightMouseButton(e))
{
}
}
});
Right now the MouseEvent e contains only the selected item, is there a way to detect which one is the mouse clicked item ? What I want to achieve is save a step : left-click on item 3 then right click on it to do extra process. But I want to skip the left-click.
Aucun commentaire:
Enregistrer un commentaire