关于jtable中的鼠标双击事件的问题 重写你的cellEditor(extends DefaultCellEditor),在里面监听你想要的消息. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 单元格的编辑默认是由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)就行了。 运行出现如下异常 N后问题! 关于中文编码转换的问题 菜鸟求救 编程问题 Java 的Calendar 中一个极其古怪的问题 [线程问题]怎样监控执行时间来决定当前操作任务是否因超时停止呀? 问题可大了,靠有人回答么? Resin作服务器,原来Tomcat/common/classes目录下的东西现应放在哪里? 您好,想学Java,请您指导,谢谢 JBuilder中怎么没有画图的呢? 关于在jbuilder 中调用 ilog jtgo的组件问题
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)就行了。