# Accessing PApplet methods in static

**URL:** <https://discourse.processing.org/t/accessing-papplet-methods-in-static/23112>\
**Category:** Beginners\
**Created:** [August 7, 2020, 5:36pm UTC](https://discourse.processing.org/t/accessing-papplet-methods-in-static/23112 "2020-08-07T17:36:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SemAntys](https://avatars.discourse-cdn.com/v4/letter/s/ecccb3/32.png) [@SemAntys](https://discourse.processing.org/u/SemAntys)\
**Post date:** [August 7, 2020, 5:36pm UTC](https://discourse.processing.org/t/accessing-papplet-methods-in-static/23112/1 "2020-08-07T17:36:42Z")

</div>

Hi, I’m trying to access PApplet methods in a static class, in this case the color() method. I’ve tried following [this discussion](https://discourse.processing.org/t/use-random-in-static-method/21358), but I can’t make it work.  
I’ve written this:

```auto
static class myclass {
  
  static int mycolor(final PApplet p) {
    int out = p.color(0);
    return out;
  }
  
}

```

but it doesn’t compile due to “unexpected token: int”.

I don’t really know what I’m doing wrong, hope you can help me!

---

<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:** [August 7, 2020, 6:56pm UTC](https://discourse.processing.org/t/accessing-papplet-methods-in-static/23112/2 "2020-08-07T18:56:32Z")

</div>

> [@SemAntys](#):
>
> I don’t really know what I’m doing wrong, hope you can help me!

You’re doing alright! It’s a PDE’s pre-processor bug! 🐛

B/c the name color is both a Processing’s datatype: `color`

> **[color / Reference](https://processing.org/reference/color_datatype.html)**
>
> Datatype for storing color values. Colors may be assigned with get() and color() or they may be specified directly using hexadecimal notation such as #FFCC00 or 0xFFFFCC00.…

And a PApplet & PGraphics method name: **color()**

> **[color() / Reference](https://processing.org/reference/color_.html)**
>
> Creates colors for storing in variables of the color datatype. The parameters are interpreted as RGB or HSB values depending on the current colorMode(). The default mode is RGB values fr…

It seems like the name color can’t be used w/ the [dot](https://processing.org/reference/dot.html) `.` operator within a “.pde” file. 😲

This example calling **color()** as a method of a PGraphics object also triggers this bug: 🔫

```auto
final PGraphics pg = createGraphics(10, 10);
pg.color(0); // unexpected token: .
exit();

```

As a workaround, you can place your static classes in a “.java” file instead. 💡

You just need to remove the `static` keyword before `class`, b/c top classes inside “.java” files are implicitly static already. 😉

You should also report this issue on Processing’s repo: 🐙

> **[Issues · processing/processing](https://github.com/processing/processing/issues)**
>
> Source code for the Processing Core and Development Environment (PDE) - Issues · processing/processing

---

<div class="post-metadata">

**Author:** ![SemAntys](https://avatars.discourse-cdn.com/v4/letter/s/ecccb3/32.png) [@SemAntys](https://discourse.processing.org/u/SemAntys)\
**Post date:** [August 7, 2020, 8:24pm UTC](https://discourse.processing.org/t/accessing-papplet-methods-in-static/23112/3 "2020-08-07T20:24:22Z")

</div>

Thank you for your help and your workaround! I will do that =)

I’ve also created an issue, [here is the link to it](https://github.com/processing/processing/issues/6083) for future viewers.
