我有两个问题要问
第一个问题
向ListSelectionListner事件添加JTable事件的最佳方法(就性能而言)是什么?
这是:
myTable.getSelectionModel().addListSelectionListener(this);或者这个:
myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
//Do my stiff here...
}
}
});第二个问题:
我有这样的代码:
myFirstTable.getSelectionModel().addListSelectionListener(this);
mySecondTable.getSelectionModel().addListSelectionListener(this);我怎么知道是哪个JTable触发了ListSelectionListner事件?
发布于 2015-02-07 09:20:53
第1部分
不相干,无论是好是坏,从性能的角度来看,都会归结为需求。显然,如果将单个侦听器添加到多个表中,则从内存角度看,它将更有效。
你会用它来决定你的需要和你想要达到的目标。
第2部分
使用ListSelectionEvent#getSource方法确定实际触发事件的内容
https://stackoverflow.com/questions/28380288
复制相似问题