# Deeply-layered nested classes

**URL:** <https://discourse.processing.org/t/deeply-layered-nested-classes/805>\
**Category:** Coding Questions\
**Created:** [June 9, 2018, 9:29am UTC](https://discourse.processing.org/t/deeply-layered-nested-classes/805 "2018-06-09T09:29:10Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 6, 2018, 5:43pm UTC](https://discourse.processing.org/t/deeply-layered-nested-classes/805/10 "2018-07-06T17:43:34Z")

</div>

> [@FurryNightShade](#):
>
> Yes, but I don’t want want to move outside the PApplet subclass, because I need to draw stuff.

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.

---

_[View the full topic](https://discourse.processing.org/t/deeply-layered-nested-classes/805)._
