You can try something like this:
JList list = new JList(dataModel);
...
MouseListener mouseListener = new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
if (e.getClickCount() == 2)
{
int posicion = list.locationToIndex(e.getPoint());
list.setSelectedIndex(posicion);
}
else if (e.getClickCount() == 1)
list.clearSelection() ;
}
};
list.addMouseListener(mouseListener);
Tell me if this works ... I can't check it here.
source
share