Inheritance override draw()

Thank you for you reply Kevin. I attempted reply to the notification email but it was stopped because the forum does not recognise gmail, only googlemail, despite them being the same.

I am heartened by your use of the term ‘little weird’ instead of ‘big weird’.
In answer to your points…

This was a concocted minimised example to solve one issue in a larger situation. Pane and panel are a inheritance chain. In the actual (not the example of principle) the pane class is inherited by other classes. Panel inherits more than one pane of different size and position and also inherits from other classes such as buttons and titlebar. It works (now).

By encapsulating the objects I am able to make the whole chain invisible or not (with if(visible) in each draw() ) as a single entity, rather than having to hide each individually with external code.

Without the call to super the parent draw is not executed but instead fully overriden by the child, as illustrated by removing the super call. You suggest it is weird to use super, but not in the oop books that I have read.
One aim is the self drawing of objects (registerMethod() ) instead of cluttering the main draw() with a long list of objects and code.

I actually fail to see the gain in pan.draw() over super.draw() but the disadvantages are what caused me to take this route and it is not clear from your post where the void draw() is; whether it is the main draw() or is it in the panel, (a fuller example might be clearer :slight_smile: ). If it is the main then it defeats my aim of encapsulation; in the same way each of my classes has its own mousePressed() method accessed by a simple one line external call.

All detail is encapsulated within each class and is thus (to me) less confusing than an external string of code for all mousePressed() events in one place. The encapsulation thus also aids debugging.

If I am wrong, please advise with reasoning so that I may improve my code and/or encapsulation methodology.

Kevin, as an addendum, I also use within Panel class void setPanePosition(x,y …) and then use x + super.x to make the external call parameters of pane relative to the panel and not the world; if this makes sense. That is also super within the child.