How to close/destroy SimpleOpenNI object

Hello everyone

I am using Processing in Eclipse and SimpleOpenNI.

I have the problem with closing SimpleOpenNI object. Is there way to close SimpleOpenNI context and intialize it again in another PApplet, but in the same application?

My programs starts and I have to options to pick from: record or play. Both of them are PApplets. When I pick one of them and close them, JFrame with PApplet dispose and I make new MenuFrame(program doesn't close) This one which I choose as first always run without problem, but when I try to pick another one(after disposing first JFrame and destroy PApplet) I have error:

Exception in thread "Animation Thread" java.lang.NullPointerException at menu_processing.RecordSketchKinect.setup(RecordSketchKinect.java:52) at processing.core.PApplet.handleDraw(PApplet.java:2361) at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240) at processing.core.PApplet.run(PApplet.java:2256) at java.lang.Thread.run(Unknown Source)

I'm trying to close SimpleOpenNI object by writing:

this.frame.dispose(); this.destroy(); this.dispose(); new MenuFrame();

where "this" is PApplet and MenuFrame is JFrame where I can pick what I want to do.

Anyone can help?

Thanks in advance

Answers

  • Answer ✓

    I found solution by creating PApplet parent = new PApplet() and context = new SimpleOpenNI(parent) in main class. After in right PApplet in setup(): MainClass.parent = this; kinect = MainClass.context; kinect.enableRGB();

    It worked and I need only one initialization :)

Sign In or Register to comment.