IntelliJ IDEA Processing

Hey everyone, I have a quick question about using another IDE for Processing. I have successfully made IntelliJ IDEA work with Processing by including the classpaths with the Java sdk as a separate sdk for processing. My only issue so far arises when I try to have multiple classes in the project. It seems that even though I extend PApplet for each class I write, the PGraphics object "g" is not properly being set. Whenever I try to do something involving graphics in a separate class like modifying the stroke, fill or drawing an ellipse I get a NullReferenceException. After some debugging, I discovered that g is not being assigned. As a quick workaround, I am passing the main class's g to every constructor, but that feels clunky. Does anyone know of a better way to do this?

Answers

    • In Processing's IDE (PDE), all the contents of all the ".pde" tab files are inside 1 PApplet subclass.
    • And all of our other classes become nested to that wrapper PApplet subclass.
    • That's why all Processing's API are directly available to ".pde" files b/c they are actually 1 top class.
    • You either follow this nested class model or you're gonna need to pass its reference to other top classes that need it.
    • Read this other forum thread about it: https://forum.Processing.org/two/discussion/22867/multiple-classes-using-display-in-netbeans
  • I am passing the main class's g to every constructor, but that feels clunky.

    No, that's the way to do it.

Sign In or Register to comment.