Something like this should work:
table.getSelectionModel().addListSelectionListener(new ListSelectionListener()
{
@Override
public void valueChanged(ListSelectionEvent e)
{
if (!e.getValueIsAdjusting())
{
boolean rowsAreSelected = table.getSelectedRowCount() > 0;
button.setEnabled(rowsAreSelected);
}
}
});
source
share