Java JTable getting the data of the selected row

前端 未结 4 1991
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-01 18:43

Are there any methods that are used to get the data of the selected row? I just want to simply click a specific row with data on it and cli

4条回答
  •  不思量自难忘°
    2021-01-01 19:41

    if you want to get the data in the entire row, you can use this combination below

    tableModel.getDataVector().elementAt(jTable.getSelectedRow());
    

    Where "tableModel" is the model for the table that can be accessed like so

    (DefaultTableModel) jTable.getModel();
    

    this will return the entire row data.

    I hope this helps somebody

提交回复
热议问题