I can create arrays of G4P objects and access them using an index or subscript, but I don’t seem to be able to append to an array of G4P objects. I get an error message “cannot convert from Object to GPanel[]” on the line with “append()”. This works for arrays of other types of object such as Strings. Is there something special about G4P objects? I do have a reason for wanting to do this, although it’s not obvious from this stripped-down example.
Here’s my source code:
import g4p_controls.*;
public void setup() {
size(800,600,JAVA2D);
String[] sa = {};
sa = append(sa, "MA");
println(sa.length);
for (int i=0; i < sa.length; i++) println(sa[i]);
GPanel[] panels = {};
GPanel panel = new GPanel(this,0,0,200,200);
panels = append(panels,panel);
println(panels.length);
}
public void draw() {
}