Java variable scope
Hi. At the moment I am writing my first game in Java and I have trouble getting my head round scope for variables in Java.
In my game I have the main JFrame class which holds an array of characters which is passed to a JPanel class for drawing. I pass this array into the JPanel in the JPanels constructor to a duplicate array. I then have a do-while loop in the JFrame class to refresh the duplicate array at .5 sec intervals.
What I want to know is, can i reference the original array in the parent from the JPanel class like I would for a child class(ie. parentclass.variable). I thought I could use 'super.variable = ...etc' but that doesn't work and the two Java books I have don't really delve into this too much. Am I trying to do something that isn't possible?
I tried putting the static keyword infront of the variable in the JFrame class so it would be allocated memory instead of being held in the stack but this has no effect, I still have to refresh the JPanel array to get the sprites to move.
The reason I ask is that it seems to be wasteful to create duplicate arrays when I want them to hold up to 4-5000+ entries. My game works the way I have it but it barley gets 10fps in a screen near the edge of my map to 0 to 1-2fps over land or where there is sprites.
I don't know if this matters but I am using the graphics class as opposed to the 2D API. Again this is due to my books only touching on these subjects(they only detail drawing shapes but i want to use GIFS for sprites). Is there any free online guides to using this with examples or am I barking up the wrong tree.
I can provide my code if required.
If anyone can give me pointers, help, advice - anything I would be grateful
Thanks

