Global variables and for loops
815854Nov 17 2010 — edited Nov 17 2010Hi,
I'm working on my project for my programming class (a Connect 4 game), and am now down to the gritty step of rewriting the whole code to make it look mildly professional. The original was this... disaster: http://zephyr.pastebin.com/7kfyaMRY -- yes, I know that will probably make any of you cringe. I'm trying to avoid the massive string of JPanel panelXxY = new JButton(""); by using for loops. I need to keep the variables global so that I can call them in my actionPerformed method, but apparently you can't put a for loop outside a method or main, and even if you could, apparently any variables declared in said for loop wouldn't exist outside that loop. So, any suggestions? Keep in mind that I've only even known what a String is for about... 10 weeks, so please nothing too complicated.
Thanks~