Can someone provide an example of the insertRow() function with a Table? I can't search the old forums and I'm just looking for a simple example to get me on my way. I looked up the Table Class and I'm stuck.
Thanks @hamoid and @Philho. So it wasn't just me then. I made a few attempts with no results. I came up with a function that is a bit clunky, by copying and shifting rows down, but it works. Thanks for looking into it.
Answers
Looking at the source code I get the impression it should be something like this:
But it gives an ArrayIndexOutOfBoundsException.
Anyone who has used insertRow()?
Indeed, it fails. I tried a variant:
With same outcome... :-(
This API is still young, still lacking documentation, and perhaps under-tested. I haven't found an example of usage of insertRow(), for example.
Perhaps we should raise a bug report about this function?
Yes, the bug is in the line:
If we insert at pos 1 with two rows, we must copy 1 element at
insert+1
, whilerowCount - insert + 1
is 2.https://github.com/processing/processing/issues/2137
Thanks @hamoid and @Philho. So it wasn't just me then. I made a few attempts with no results. I came up with a function that is a bit clunky, by copying and shifting rows down, but it works. Thanks for looking into it.
Looks like with the new beta of 2.1, the insertRow() function is working just fine!