有阿MouseEvent有一个属性,叫做clickcount哦
解决方案 »
- 可以将方法作为一个参数传递到另一个方法中吗
- 为什么把isStop()作为System.out.println()的参数执行就正确?
- 请教 我想打印出开方的那个符号, 即根号, 对应的unicode码是多少呢?
- 请教一个技术问题
- 请问有无办法设置一JFrame或JPanel里所有元件都使用同一字体?
- 用JAVA能不能写魂斗罗或街霸,拳皇之类的东西,?
- 求助java语法
- ★大侠帮忙★一个简单的问题★
- {?}我用下面的方法,给toolbar里面的button加事件,是不是可以呢?
- 请问一个乱码的问题!另外解决的话,可以追加100分!!
- ImageIcon怎么转换为BufferedImage或RenderedImage
- 关于getBytes()
/**
* 如果鼠标点击次数等于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,"我是");
}
}