aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes ListSelectionListener and double clicks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "ListSelectionListener and double clicks" Watch "ListSelectionListener and double clicks" New topic
Author

ListSelectionListener and double clicks

Kevin Hamrick
Ranch Hand

Joined: Aug 30, 2004
Posts: 32
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

Joined: Aug 30, 2004
Posts: 32
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

Joined: Aug 20, 2004
Posts: 138
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

}
}


Download Java GUI Builder, <a href="http://www.mars3000.com" target="_blank" rel="nofollow">http://www.mars3000.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ListSelectionListener and double clicks