Here's an excerpt of the init of the object:
...
Rectangle b1 = tenBullets.getBounds();
...
Here's the getBounds() method:
public Rectangle getBounds() {
return new Rectangle(x, y, 200, 25);
}
And here is the console message:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at test.game.Board.checkCollisions(Board.java:75)
at test.game.Board.actionPerformed(Board.java:53)
at javax.swing.Timer.fireActionPerformed(Unknown Source)
at javax.swing.Timer$DoPostEvent.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Board.java:75 is when the getBounds() method is called. Sometimes the exception is thrown, and 1 out of the 10th time it's not. Any fixes?