I have a button click event on which I get the column value if a row is selected Table. But if I do not select the line and press the button, I get the error: java.lang.ArrayIndexOutOfBoundsException:-1My question is: how can I check if the pseudo-code line was selected:if(Row == selected) { execute }
java code i have:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
try
{
int row = Table.getSelectedRow();
String Table_click = (Table.getModel().getValueAt(row, 0).toString());
} catch (Exception e)
{
JOptionPane.showMessageDialog(null, e);
}
}
Thank you for your help.
user3747557
source
share