Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ListSelectionListener and double clicks

 
Kevin Hamrick
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So here is the code below. The problem is that each time I select a cell from the table the 'else' is executing twice. I am not sure how to fix it. Still new and still struggling with swing,
Thanks

 
Kevin Hamrick
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
correction-the "if" is executing twice...I posted some code where I was trying some different things...my mistake. Either way, if I click the selected cell then I get to executions.
 
Pat Hays
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kevin

See the following code using if(!e.getValueIsAdjusting())
---------------
private void jList1_valueChanged(ListSelectionEvent e)
{
System.out.println("\njList1_valueChanged(ListSelectionEvent e) called.");
if(!e.getValueIsAdjusting())
{
Object o = jList1.getSelectedValue();
System.out.println(">>" + ((o==null)? "null" : o.toString()) + " is selected.");
// TODO: Add any handling code here for the particular object being selected

}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic