有阿MouseEvent有一个属性,叫做clickcount哦

解决方案 »

  1.   

    MouseAdapter {
            /**
             * 如果鼠标点击次数等于nClicksNeeded,就弹出时间选择器.
             * @param e
             */
            public void mouseClicked(MouseEvent e) { 
                if (e.getClickCount() != 2)
                    return;
      

  2.   

    getClickCount
    public int getClickCount()Returns the number of mouse clicks associated with this event. Returns:
    integer value for the number of clicks
      

  3.   

    table.addMouseListener(new MouseAdapter()
                                   {
                                     public void mousePressed(MouseEvent e)
                                     {
                                       if (e.getClickCount() == 2)
                                       {
                                         System.out.println("double click!!!");
                                       }
                                     }      
                                   });向上面的方法么??这种方法是java处理双击事件的正规处理方法么??也就是大家都这么用??
      

  4.   

    你可以判断两次鼠标点击的时间间隔,当时间间隔小于某个值时,就认为是双击
    我模拟实现了,效果不错
    public boolean checkClickTime()
    {
    long nowTime = (new Date()).getTime();
    if((nowTime-clickTime)<300)
    {
    clickTime = nowTime;
    return true;
    }
    clickTime = nowTime;
    return false;
    }
    clickTime 定义为全局变量,就可以实现!!!!
    楼主试试,效果好的话别忘了加分哈^_^
      

  5.   

    关键在于这个时间间隔怎么确定,在windows下用户可以设定的,如果用户设定了100,而我们的程序却固定的300,不太好。
    分嘛, 呵呵,肯定给你加,:)
      

  6.   

    public void mouseClicked(MouseEvent e) { 
                if (e.getClickCount() == 2)
                {
                    System.out.println("Double Click");
                }
    }
      

  7.   

    public void mouseClicked(MouseEvent e) 
    {
    // TODO: Add your code here
    if (e.getButton()==1)/
    {
    if (e.getClickCount()==2)
    javax.swing.JOptionPane.showMessageDialog(null,"我是");
    }


    }