I have written an Java Processing application. If I try to start it, I get the following error:
""processing.core.PGraphics.createShape(int, float[])" because "this.g" is null".
My Application has a View, Controller and Modell. They only interact through interfaces with each other. My Modell-Classes extend PApplet and create some shapes, but I also get errors in my view. Maybe something is not passed on correctly.
I know, that the error may be caused, because I try to call a method on an object that has not been initialized yet. In this case the processing.core.PGraphics.createShape(int, float) method on this.g.
My PApplet window opens, but nothing is drawn on it.
Could someone please look into it?
I tried to create instances of PApplet and/or Graphic in my View class and pass it in to my controller class; e.g.:
my View, where the objects are drawn.
public class xyView extends PApplet implements ILeiterspielView {
public static void main(String args) {
PApplet.main(LeiterspielView.class);
}
…
private static PApplet instance;
//other attempt: PApplet p = this;
//other attempt: PApplet p;
…
public xyView (other examples/PApplet pa//Graphics gd/) {
instance = this;
//this.gd = gd;
//this.p = pa;
setSize(1000, 1000);
}
public void setup (/Dice[] dice//this/) {
this.controller = new xyController(this, width, height, instance);
…
}
my controller, the interface between the view and model.
public LeiterspielController (IxyView view, …, PApplet p) {
this.view = view;
this.game = new xyModel();
this.p = p;
…
}
My first solution doesn’t change the outcome.
The PApplet p = this solution changes the outcome to:
java.lang.RuntimeException: java.lang.NoSuchMethodException: leiterspiel.view.LeiterspielView.()
I don’t know what this means and the PApplet window doesn’t open.