
-----------------------------------
Shivu
Sun May 11, 2008 8:54 pm

APPLETS!-- And ARRAYS!
-----------------------------------
hey!!

i need help with 2D arrays. not particularly applets because our teacher wrote the code for appelts for us since we didn't learn them yet. So, a brief intro of what i've to do: there is a 2D array of type Color. so, when you press a certain F key (function key on the keyboard) different patterns of colours come up on the screen= in other words on the applet window...

so, my problem:  when you press F5, the "columns " of the colours in the array are supposed to move one to the left. (the array is 4X4) 

I don't know how to keep the colours stable, meaning that everytime i press F5, the colours of the array change. I don't know how to "store " those colours in some way so that whenever you press F5 those same colours in the columns will move one to the left.

here's my code- (it's only the part where i wrote my stuff about the shifting... and other stuff :S)


 public void shiftLeft ()
      {
      // Step 5:  Cause each column on the grid to shift left.
      // The first (left most) column will shift to the last (right most) column
         int color1 = (int)(Math.random()*255);
         int color2 = (int)(Math.random()*255);
         int color3 = (int)(Math.random()*255);
      
         Color temp1= Color.white;
      
         for (int i =0; i