final String cardListStrings[] = {"First Card", "Next Card", "Previous Card", "Last Card"};
cardList = new JList(cardListStrings);
cardList.setVisibleRowCount(4);
cardList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
cardList.addListSelectionListener(
new ListSelectionListener()
{
public void valueChanged(ListSelectionEvent e)
{
System.out.println("Inside List Event Handler");
if (cardList.getSelectedIndex()== 0)
{
cardManager.first(deck);
System.out.println("First Card");
}
if (cardList.getSelectedIndex()== 1)
{
cardManager.next(deck);
System.out.println("Next Card");
}
if (cardList.getSelectedIndex() == 2)
{
cardManager.previous(deck);
System.out.println("Previous Card");
}
if (cardList.getSelectedIndex()== 3)
{
cardManager.last(deck);
System.out.println("Last Card");
}
}
}
);
This piece of code fires twice for every selection in the JList Menu. How do I get it to fire once for each mouse click.
Thanks