This site requires JavaScript, please enable it in your browser!
Greenfoot back
hamchi
hamchi wrote ...

2012/10/29

NullPointerexception error

hamchi hamchi

2012/10/29

#
MouseInfo muis = Greenfoot.getMouseInfo(); if( muis.getClickCount() == 5){ JOptionPane.showMessageDialog(null,"fdfd"); } i want to get this thing to work, i want it to display a message when the object is clicked on 5 times what am i doing wrong guys
davmac davmac

2012/10/29

#
Greenfoot.getMouseInfo() can return null. You need to check for a null value before calling 'getClickCount()'.
MouseInfo muis = Greenfoot.getMouseInfo();

if (muis != null && muis.getClickCount() == 5) {
    JOptionPane.showMessageDialog(null,"fdfd");
}
hamchi hamchi

2012/10/29

#
no way! thats why it wasnt working? isnt it a bit obvious the return value ISNT null when it has to equal 5? i mean come on...i failed the entire assignment during the examn because of that bitch
davmac davmac

2012/10/29

#
When you write a program, you're talking to the computer (specifically, the compiler) - it doesn't think like you do. It does exactly what you tell it, no more, no less.
You need to login to post a reply.