public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { System.out.println("Double Click"); } }
public void mouseClicked(MouseEvent e) { // TODO: Add your code here if (e.getButton()==1)/ { if (e.getClickCount()==2) javax.swing.JOptionPane.showMessageDialog(null,"我是"); }
/**
* 如果鼠标点击次数等于nClicksNeeded,就弹出时间选择器.
* @param e
*/
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() != 2)
return;
public int getClickCount()Returns the number of mouse clicks associated with this event. Returns:
integer value for the number of clicks
{
public void mousePressed(MouseEvent e)
{
if (e.getClickCount() == 2)
{
System.out.println("double click!!!");
}
}
});向上面的方法么??这种方法是java处理双击事件的正规处理方法么??也就是大家都这么用??
我模拟实现了,效果不错
public boolean checkClickTime()
{
long nowTime = (new Date()).getTime();
if((nowTime-clickTime)<300)
{
clickTime = nowTime;
return true;
}
clickTime = nowTime;
return false;
}
clickTime 定义为全局变量,就可以实现!!!!
楼主试试,效果好的话别忘了加分哈^_^
分嘛, 呵呵,肯定给你加,:)
if (e.getClickCount() == 2)
{
System.out.println("Double Click");
}
}
{
// TODO: Add your code here
if (e.getButton()==1)/
{
if (e.getClickCount()==2)
javax.swing.JOptionPane.showMessageDialog(null,"我是");
}
}