选中行
table.getSelectionModel().setSelectionInterval(startRowIndex, endRowIndex);
监听选择事件
table.getSelectionModel().setSelectionInterval(startRowIndex, endRowIndex);
监听选择事件
table.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
@Override
public void valueChanged(ListSelectionEvent e)
{
int row = table.getSelectedRow();
if(row != -1)
{
XXXModel model = (XXXModel)tbEmpList.getModel();
}
}
});
本文介绍了一种在Java Swing中实现表格行选择的方法,并通过监听选择事件来获取被选中的行索引。此示例使用了setSelectionInterval方法来设置选中范围,并添加了一个ListSelectionListener来监听选择变化。
1525

被折叠的 条评论
为什么被折叠?



