Thank you Kevin, The purpose was to test whether I could override the draw() method in a parent by only adding new items in a child rather than having to re-draw (in the child) the parent as well as the child extras.
It appeared not to be possible, however…
your comment focused my mind on providing an example which ended up curing the problem.
I had made the simple mistake of making two rectangles the same size on top of each other, which masked the intended result.
In fact it was possible, as you will know anyway, but I did not.
I had better add the example here lest I risk my other hand being slapped
Take the comment marks off the line with super.draw()
Panel pan;
void setup(){
size(500,500);
pan = new Panel(150,150,150,150,color(0,255,0));
pan.pane.labClr=color(255,255,0);
pan.setCaption("Green",color(255,0,0));
pan.pane.setCaption("Yellow",color(255,0,0));
}
void draw(){
background(0);
}
//===============================================================
public class Pane {
int x, y, w, h;
int labClr, capClr;
String caption="";
Pane(int _x, int _y, int _w, int _h,int _labClr) {
x = _x; y = _y; w = _w; h = _h; labClr = _labClr;
registerMethod("draw",this);
}
//--------------------------------------------------------------
void setCaption(String _caption, int _capClr) {
caption=_caption; capClr=_capClr;
}
//--------------------------------------------------------------
void draw() {
fill(labClr);
noStroke();
rect(x, y, w, h);
textAlign(RIGHT,CENTER);
fill(capClr);
text(caption,x+w/2,y+h/2);
}//draw
}
//===============================================================
public class Panel extends Pane {
Pane pane;
Panel(int _x, int _y, int _w, int _h,int _labClr){
super(_x, _y, _w, _h, _labClr);
pane = new Pane(x+70,y+70,w-70,h-70,labClr);
}
void draw(){
// super.draw();
stroke(255);
line(x+30,y+30,x+30,y+230);
line(100,100,x+250,y+150);
}
}