Name

addRow()

Class

Table

Description

Use addRow() to add a new row of data to a Table object. By default, an empty row is created. Typically, you would store a reference to the new row in a TableRow object (see newRow in the example above), and then set individual values using setInt(), setFloat(), or setString(). If a TableRow object is included as a parameter, then that row is duplicated and added to the table.

Examples

  • Table table;
    
    void setup() {
    
      table = new Table();
      
      table.addColumn("name");
      table.addColumn("type");
      
      TableRow newRow = table.addRow();
      newRow.setString("name", "Lion");
      newRow.setString("type", "Mammal");
      println(table.getRowCount());  // Prints 1
      
      table.addRow();  // Creates a new blank row
      println(table.getRowCount());  // Prints 2
      
      table.addRow(newRow);  // Duplicates newRow
      println(table.getRowCount());  // Prints 3
    }
    

Syntax

  • .addRow()
  • .addRow(source)

Parameters

  • source(TableRow)a reference to the original row to be duplicated

Return

  • TableRow