hello007
hello007

Reputation: 29

how to get specific column's value after using filter

I have used TableRowsorter to filter some rows out from myJtable. Is there a way I can take all the values from a column and store it in arraylist after the filter from the Jtable.

Upvotes: 0

Views: 151

Answers (1)

MadProgrammer
MadProgrammer

Reputation: 347204

Conceptually, something like this...

// Apply filter...
int col = ...; // Column you're interested in
List values = new ArrayList(table.getRowCount());
for (int row = 0; row < table.getRowCount(); row++) {
    values.add(table.getValueAt(row, col));
}

will work.

Because JTable is a representation of the filtered (and sorted) data, you can just walk through it to get the values it's presenting

Upvotes: 1

Related Questions