Double click in LIST
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Virgilio_Garcia
Posted On:   Wednesday, August 22, 2001 02:18 AM

I have this source code: private long segundo = 0; LIST.addItemListener(new ItemListener(){ public void itemStateChanged(java.awt.event.ItemEvent e) { if (segundo == 0) { segundo = java.util.Calendar.getInstance().getTime().getTime(); System.out.println("First click"); }else { if ((java.util.Calendar.getInstance().getTime().getTime() - segundo) <= 500) { System.out.println("Second click"); segundo = 0; }else { LIST.deselect(LIST.getSelectedIndex()); segundo = 0; } } } }); Why I have to click three times for see in my console "Second click" ?    More>>

I have this source code:

			
private long segundo = 0;
LIST.addItemListener(new ItemListener(){
public void itemStateChanged(java.awt.event.ItemEvent e) {
if (segundo == 0) {
segundo = java.util.Calendar.getInstance().getTime().getTime();
System.out.println("First click");
}else {
if ((java.util.Calendar.getInstance().getTime().getTime() - segundo) <= 500) {
System.out.println("Second click");
segundo = 0;
}else {
LIST.deselect(LIST.getSelectedIndex());
segundo = 0;
}
}
}
});

Why I have to click three times for see in my console "Second click" ?    <<Less
About | Sitemap | Contact