I have a boolean
which checks if an action is to be performed or not, the boolean
is being being accessed through setters and getters
, I have other booleans
am accessing in a similar way and they are not giving me any errors except this one, at first I was checking it in a piece of code within a seperate thread and that part was not working without producing an exception so I put it in a toggleButton
just to do a simple read
and write
on it, then the nullPointerException
came up, here is my code I have commented it
toggleButton.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent event) {
//this part is executing perfectly
//meaning my toggleButton is ok
System.out.println("Toggle Button Clicked");
//this is where I am getting the NullPointerException
if(!getblackAndWhite()){
setblackAndWhite(true);
}else{
setblackAndWhite(false);
}
}});
private void setblackAndWhite(Boolean blackAndWhite)
{
this.blackAndWhite = blackAndWhite;
}
private Boolean getblackAndWhite()
{
return this.blackAndWhite;
}