从单元格中检索 JTable 的行号

retrieve the row number of a JTable from a cell

我需要知道是否可以通过单击位于 table 内部的按钮来检索 JTable 的行号。我需要从特定单元格中获取行数

当您单击 table 中的单元格时,该行将被选中。

要确定所选行,您可以使用:

int row = table.getSelectedRow();