smooth() can only be used inside settings()
Exception in thread "Animation Thread" java.lang.NullPointerException
at Test2.doThing(Test2.java:12)
at Test1.dosomething(Test1.java:15)
at ExampleApplet.draw(ExampleApplet.java:101)
at processing.core.PApplet.handleDraw(PApplet.java:2401)
at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1499)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:312)

I get a NullPointerException because PApplet does not get passed(?)
is there a workaround or a simple solution for this?

Best Answer

Answers

The first message about smooth is just a warning. Make your own settings() and setup() methods in your main class if you want to get rid of it.

The null pointer error is because in the Test1 class, you declare and initialise a Test2 object using a reference to its parent PApplet variable at object creation, before the constructor, which is always null. You should only initialise the Test2 object in or after the constructor:

Problem was that it was getting too big, the processing IDE only feels comfortable if the number of classes used are small, and it gets cluttered very quickly, too much code, too much classes. That is why I migrated my project to Intelij. But I was a bit wary from doing this in the first place because of this PApplet issue... now its solved