Deeply-layered nested classes

Placing code in “.java” files instead of “.pde” was just an advise.
Declaring nested classes as static is pretty close to the same behavior of top classes in “.java” files after all.

However, whether a class is top, static or inner, got nothing to do w/ drawing stuff or not!

If a top class couldn’t do it like you state, how is it possible that libraries written for Processing are able to?

The trick is to request the PApplet’s reference in their constructor, store it as a field, and then use it in order to draw on that PApplet’s canvas.

Nested static classes can do the same as top classes. Just demand the PApplet’s reference.

2 Likes