重写你的cellEditor(extends DefaultCellEditor),在里面监听你想要的消息.

解决方案 »

  1.   

    单元格的编辑默认是由DefaultCellEditor类来维护。这个类由个clickCountToStart属性,它决定鼠标单击多少次开始编辑单元格,可通过getClickCountToStart()和setClickCountToStart(int n)来获得得设置这个属性。
    DefaultCellEditor类中有个内部类EditorDelegate,它来处理鼠标事件。这个内部类有个和DefaultCellEditor类中同名的isCellEditable方法,是这样写的:
    public boolean isCellEditable(EventObject anEvent) {
     if (anEvent instanceof MouseEvent) { 
      return ((MouseEvent)anEvent).getClickCount() >= clickCountToStart;
      }
      return true;

    而DefaultCellEditor类的同名方法其实就是调用其内部类的这个方法。因此,你要这样做,扩展DefaultCellEditor类,重写isCellEditable方法:
      public class MyEditor extends DefaultCellEditor {
            public boolean isCellEditable(EventObject e) {
                if (e instanceof MouseEvent
                    && ((MouseEvent)e).getClickCount() >= clickCountToStart) {
                    //显示对话框
                    return true;
                }
                return false;
          
            }
        }
     
    最后表格再setCellEditor(MyEditor)就行了。