Results 1 to 4 of 4
Thread: Game of Life GUI Error
- 01-03-2011, 12:20 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 2
- Rep Power
- 0
Game of Life GUI Error
I'm attempting to build a GUI for a console-based Game of Life game I've already developed. I went about it by building the very basic GUI (a grid with red squares that are either on or off with JButtons to control), then integrating a Game of Life concept into it (where I render the original grid with a random feature, then analyse it and create a new tempgrid with the new data, clear the original and interchange them, then clear the tempgrid).
The GUI runs, but when starting the game via the JButton the following error occurs:
I've checked and re-checked my code, and I genuinely have no idea on where to start fixing this error, the text version runs perfectly but this refuses to work even though I use the exact same concepts. If you require any more of the classes involved, please ask as I'll be watching this thread all day and can reply instantly.Java Code:Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at ClickGame.prepareNextGeneration(ClickGame.java:21) at StartListener.actionPerformed(StartListener.java:27) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(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)
Thank you in advance.Last edited by Lavace; 01-03-2011 at 02:03 PM.
- 01-03-2011, 01:23 PM #2
Crossposted: Game of Life GUI Error - Java Programming Forums
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 01-03-2011, 01:39 PM #3
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Maybe this will help.
- 01-03-2011, 01:57 PM #4
Member
- Join Date
- Dec 2010
- Posts
- 2
- Rep Power
- 0
Thanks to Kevin,
I done some research on your suggestion and realised that I had declared the preperation method static (because I was re-using this code from my console version).
As a consequence, I had to rename all the methods to static in ClickData, change the instance variables to static and as I've just learnt, change the way the methods are called.
But I do not understand why if I remove the static references, the code still points to the same error (however, only to the prepareNextGeneration() method and no references to where).
Thank you ever so much for your help, I've been stuck on this for days.
Similar Threads
-
Game of life methods help
By bigskers76 in forum New To JavaReplies: 26Last Post: 12-12-2009, 03:11 PM -
game of life
By bigskers76 in forum New To JavaReplies: 10Last Post: 12-09-2009, 05:21 AM -
2d array help- Game of Life
By n3philim in forum New To JavaReplies: 2Last Post: 07-23-2009, 12:01 AM -
A more efficient Game of Life
By unreal4evr in forum New To JavaReplies: 3Last Post: 03-27-2009, 03:08 AM -
Game of Life assignment
By javan00b in forum New To JavaReplies: 4Last Post: 04-28-2008, 05:49 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks