public void actionPerformed(ActionEvent e) {
int selRow = table.getSelectedRow();
int nCols = table.getColumnCount();
for (int i = 0; i < nCols; i++)
System.out.println(tableModel.getValueAt(selRow,nCols[i]));
}
Bruce Jin wrote:
Thanks Peter:
But I could not find a method in AbstractTableModel or TableModel that will
allow me to do this (get an object that you have in your model with a row
index).
Thanks.
Bruce
----- Original Message -----
From: "Peter Peterson" <[EMAIL PROTECTED]>
I think a better way to do this to get values from the model
and not table. After you know the index of the row that
you clicked on, just get an object that you have in your model
at that location !
- Peter
--- Ravi <[EMAIL PROTECTED]> wrote:
Hi Bruce
You can do, table.getSelectedRow() which returns the index of the
selected
row.
and then perform nCols = table.getColumnCount()
The following snippet should work.
int row = table.getSelectedRow();
int nCols = table.getColumnCount();
for (int i = 0; i < nCols; i++)
System.out.println(table.getValueAt(row, nCols[i]));
Hope this helps!
Regards.... Ravi.
----- Original Message -----
From: "Bruce Jin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, December 21, 2002 4:34 AM
Subject: Get cell values of a JTable row.
I want to get all cell values of a row (that was clicked) when I
click a
button outside the table. How to do this?
I have an action listener for this button. In the actionPerformed()
method
I
have access to the table object.
Thanks.
Bruce
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing