日期:2014-05-20 浏览次数:20837 次
SelectionListener listener = new SelectionListener(jtable);
jtable.getSelectionModel().addListSelectionListener(listener);
public class SelectionListener implements ListSelectionListener {
JTable table;
SelectionListener(JTable table) {
this.table = table;
}
public void valueChanged(ListSelectionEvent e) {
if (e.getSource() == table.getColumnModel().getSelectionModel()
&& table.getColumnSelectionAllowed() ){
int firstRow = e.getFirstIndex();
int lastRow = e.getLastIndex();
// 事件处理...
}
}
}