我已经实现了 ListSelectionListener ,如下所示,因此在选择第一个表中的特定行后,第二个表会相应更新。
class SelectionListener implements ListSelectionListener {
public SelectionListener(){}
@Override
public void valueChanged(ListSelectionEvent e)
{
if (e.getSource() == myTrumpsAndMessages.jTable1.getSelectionModel()
&& myTrumpsAndMessages.jTable1.getRowSelectionAllowed()
&& e.getValueIsAdjusting())
{
int selected = myTrumpsAndMessages.jTable1.getSelectedRow();
clearjTable(jTable4);
showSubscribers(selected);
}
}
}
有没有办法不仅在鼠标选择时调用监听器,而且在从键盘进行选择时调用监听器?