I made a maze game. When you click the button, a navigator is created. But before you create a navigator, if you try moving the navigator, there is a null pointer exception.

since the navigator can be moved by pressing keys on the keyboard, I want an error message to appear if and when user tries to move the navigator without creating a navigator.

i want to do

if nav==null //not created
error message
else
do...

how do i do this?

As per my other post i regards of key listener, please provide your code

figured it out!

try{
//code
}catch(exceptiontype name){ //this case Exception NullPointerException
}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.