java.lang.NullPointerException
in
Programming Questions
•
1 year ago
Hi,
i have 2 classes:
The StateHandler class creates 2 objects statePlay and stateEdit and starts the execute method
in the main class i start the programm with:
StateHandler statehandler = StateHandler();
StateHandler.runState();
If i press my change button i got the message:
controlP5.ControlBroadcaster printMethodError
Schwerwiegend: An error occured while forwarding a Controller event, please check your code at Change
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
Can anyone tell me why this cause an error?
i have 2 classes:
The StateHandler class creates 2 objects statePlay and stateEdit and starts the execute method
- public class StateHandler
{
PlayState statePlay;
EditState stateEdit;
State state;
State oldState;
StateHandler()
{
state_1 = new PlayState(this);
state_2 = new EditState(this);
}
public boolean changeState()
{
....
....
return true;
}
void runState()
{
state.execute();
}
}
- public class EditState extends PApplet implements State
{
public StateHandler stateHandler;
public EditState(StateHandler d)
{
this.stateHandler = d;
}
public EditState()
{
}
public void setup()
{
size(400,600);
noStroke();
cp5 = new ControlP5(this);
cp5.addButton("Change")
.setValue(0)
.setPosition(66,0)
.setSize(65,20)
;
}
public void draw()
{
}
public void controlEvent(ControlEvent theEvent) {
println(theEvent.getController().getName());
}
void Change(int theValue)
{
stateHandler.changeState();
}
public boolean execute()
{
PApplet.main(new String[] { "--present", "EditState" });
return true;
}
}
in the main class i start the programm with:
StateHandler statehandler = StateHandler();
StateHandler.runState();
If i press my change button i got the message:
controlP5.ControlBroadcaster printMethodError
Schwerwiegend: An error occured while forwarding a Controller event, please check your code at Change
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
Can anyone tell me why this cause an error?
1