Nicolas
Nicolas

Reputation: 331

java: JTable DefaultTableModel addRow(Object[] rowData)

I'm curious why DefaultTableModel has a

    public void addRow(Object[] rowData)

But no

    public Object[] getRow()

Is there a way to get an array of the row data without looping through the row cells one-by-one?

Upvotes: 0

Views: 646

Answers (1)

camickr
camickr

Reputation: 324207

Is there a way to get an array of the row data without looping through the row cells one-by-one?

You need to create a custom TableModel to support this functionality.

Check out Row Table Model and List Table Model which does implement this type of functionality for you.

Well, actually it returns the row in a List, not an Array, but you can always use the List.toArray(...) method if you really need an Array.

Upvotes: 1

Related Questions