Results 1 to 4 of 4
  1. #1
    Lavace is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Default 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:

    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)
    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.

    Thank you in advance.
    Last edited by Lavace; 01-03-2011 at 02:03 PM.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,693
    Rep Power
    8

    Default

    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Maybe this will help.

  4. #4
    Lavace is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Default

    Quote Originally Posted by KevinWorkman View Post
    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

  1. Game of life methods help
    By bigskers76 in forum New To Java
    Replies: 26
    Last Post: 12-12-2009, 03:11 PM
  2. game of life
    By bigskers76 in forum New To Java
    Replies: 10
    Last Post: 12-09-2009, 05:21 AM
  3. 2d array help- Game of Life
    By n3philim in forum New To Java
    Replies: 2
    Last Post: 07-23-2009, 12:01 AM
  4. A more efficient Game of Life
    By unreal4evr in forum New To Java
    Replies: 3
    Last Post: 03-27-2009, 03:08 AM
  5. Game of Life assignment
    By javan00b in forum New To Java
    Replies: 4
    Last Post: 04-28-2008, 05:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •