【问题标题】:retrieve the row number of a JTable from a cell从单元格中检索 JTable 的行号
【发布时间】:2016-01-04 01:49:19
【问题描述】:

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

【问题讨论】:

    标签: java swing jtable selection


    【解决方案1】:

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

    要确定您可以使用的选定行:

    int row = table.getSelectedRow();
    

    【讨论】:

    • 感谢 camickr。我的问题是我点击了名为“更新”的 JButton,我需要 PerfomedAction 方法告诉我哪一行属于该按钮
    • @rubystudent,对,所以在 ActionLitener 中,您添加到 JButton 中,添加我刚刚给您的代码行。
    猜你喜欢
    • 1970-01-01
    • 2011-09-27
    • 2012-02-23
    • 1970-01-01
    • 2011-12-07
    • 1970-01-01
    • 2011-03-16
    • 2015-07-26
    • 1970-01-01
    相关资源
    最近更新 更多