ounds().x;inty=cellNull.getBounds().y;intdirection=(int)(Math.random()*4);//产生0-4,对应空方格的上下左右移动if(direction==0){//空方格左移动,与左侧方格互换位置,左侧方格右移动x-=100;if(test(x,y)){for(intj=0;j<8;j++){
if((cell[j].getBounds().x==x)&;&;(cell[j].getBounds().y==y)){//依次寻找左侧的按钮cell[j].move("RIGHT",100);cellNull.setLocation(x,y);break;//找到后跳出for循环}}}}elseif(direction==1){//RIGHTx+=100;if(test(x,y)){for(intj=0;j<8;j++){if((cell[j].getBounds().x==x)&;&;(cell[j].getBounds().y==y)){cell[j].move("LEFT",100);cellNull.setLocation(x,y);break;}}}}elseif(direction==2){//UPy-=100;if(test(x,y)){for(intj=0;j<8;j++){if((cell[j].getBounds().x==x)&;&;(cell[j].getBounds().y==y)){cell[j].move("DOWN",100);cellNull.setLocation(x,y);break;}}}}else{//DOWNy+=100;if(test(x,y)){for(intj=0;j<8;j++){
if((cell[j].getBounds().x==x)&;&;(cell[j].getBounds().y==y)){cell[j].move("UP",100);cellNull.setLocation(x,y);break;}}}}if(!hasAddActionListener)/