I want to integrate Processing sketches in "normal" Java-programs. To do this, I have a class that contains the Processing code:
import controlP5.*;
import processing.core.*;
public class ProcessingCode extends PApplet {
public ControlP5 cp5;
public void setup () {
size( 200, 200 );
background(100);
cp5 = new ControlP5(this);
cp5.addButton("b1");
}
public void draw () {
//blablabla
}
}
And the main class, which starts everything:
public class Frame extends javax.swing.JFrame {
private ProcessingCode sp;
public Frame() { initComponents(); sp = new ProcessingCode(); sp.init();
jPanel1.add(sp);
}
...(much code)....
(only the important code is shown)
The strange thing is that it does not work, when the code contains anything from controlP5. Without this code, everything is working.
The error is the following:
Exception in thread "Animation Thread" java.lang.NullPointerException at controlP5.ControlWindow.<init>(Unknown Source) at controlP5.ControlP5.init(Unknown Source) at controlP5.ControlP5.<init>(Unknown Source) at ProcessingCode.setup(ProcessingCode.java:34) at processing.core.PApplet.handleDraw(Unknown Source) at processing.core.PApplet.run(Unknown Source)