SOLVED.
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:
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.