multiple window application causes nullpointerexception
in
Contributed Library Questions
•
3 months ago
Hi all ,
I just want to create a multiple window application. i took the basic idea from the following code
- import controlP5.*;
- ControlP5 cp5;
- PFrame f;
- thirdApplet mesg;
- Button alarm,ok;
- void setup() {
- size(400, 500);
- f = new PFrame();
- cp5 = new ControlP5(this);
- alarm=cp5.addButton("alarms")
- //.setValue(0)
- .setPosition(100,100)
- .setSize(200,19)
- ;
- }
- void draw() {
- background(0,0,255);
- fill(255);
- rect(10,10,frameCount%100,10);
- if(alarm.isPressed())
- {
- mesg.background(0,255,0);
- mesg.fill(255,0,0);
- mesg.rect(10,10,20,20);
- mesg.redraw();
- }
- }
- public class PFrame extends Frame {
- public PFrame() {
- setBounds(100,100,400,300);
- mesg = new thirdApplet();
- add(mesg);
- mesg.init();
- show();
- }
- }
- public class thirdApplet extends PApplet {
- public void setup() {
- size(400, 300);
- background(0,0,255);
- ControlP5 cp;
- cp=new ControlP5(this);
- cp.addTextfield("input")
- .setPosition(20,200)
- .setSize(200,40)
- .setFocus(true)
- .setColor(color(255,0,0))
- ;
- //.setValue(0)
- noLoop();
- }
- public void draw() {
- }
- }
i want to transfer the data i am reading through serial port from first form to the next form by clicking one button and display the data in the text field in the second window. I want to add buttons and other controlp5 controls in both the forms. But i am getting null pointer exception the line 53. How to add controlp5 objects to the second window. Any help would be appreciated. pLease respond
Regards
Arun
1