我使用ListSelectionListener监听JTable的选择,以执行表中与所选项目相关的其他任务。但是为什么下面的代码在一开始的一次选择中执行两次,并在该表被更新后多次执行呢?
public void valueChanged(ListSelectionEvent e)
System.out.println(tablelist.getSelectedIndex());
}发布于 2012-06-29 19:46:45
因为来自ListSelectionModel interface的ListSelectionListener总是触发两个事件
int firstIndex = e.getFirstIndex();
int lastIndex = e.getLastIndex();Oracle tutorial中的所有内容
https://stackoverflow.com/questions/11261015
复制相似问题