I am designing a GUI with applet. In my GUI, a picture will move from left to right. I gave the positon(0,0) as the start point, but when I run it, it doesn't seem that that picture start at (0,0). Is there any suggestion about it? Thanks a lot.
Hi Jeannie, It might be more helpful to tell us what the problem actually is. For example: The image always starts at 10,10 even though I am telling it to be at 0,0 ... Some code might even be helpful ... Regards, Manfred.
the following is part of my code. I tried to show two moving images in this page. One of the image will move from left top corner to bottom right corner. The other one is moving from bottom right corner to top left corner. The width of applet is 800 and the height of applet is 650. After I run the follwing code, one image always come from left middle instead left top. The other one come from right middle instead right bottom. So I don't know what happened to my code. Thanks. void DrawCondition2(int randomaxis, int randomCount,int ifDrawBall) { if(randomaxis == MOVE_STYLE_2) { x1pos = 0; y1pos = 50; x2pos = 700; y2pos = 650; } else { x1pos = 0; y1pos = 450; x2pos = 700; y2pos = 200; } twoImages = true; randomCount = randomInt(60); currentImg=FilterImage[randomCount]; if(randomCount < 99) randomCount = randomCount + 1; //randomCount = FilterImage[randomCount]; currentImg2=FilterImage[randomCount]; beforeTime = System.currentTimeMillis(); for(int n = 0; n < NUM_FRAMES_PER_LOOP; n++) { if(n == 14) { if (ifDrawBall!=0) drawBall=true; if(drawBall) { drawBallInit(randomInt(800),randomInt(650)); repaint(); } } if((answer != 2)&& (answer < 3)) { // repaint(); // pause(500); System.out.println("answer is: " + answer); System.out.println("the response time is: " + (afterTime-beforeTime)); //continue; break; } repaint(); pause(150); if(randomaxis == 1) { x1pos = x1pos + 25; x2pos = x2pos -25; } else { x1pos = x1pos + 25; y1pos = y1pos + 25; x2pos = x2pos - 25; y2pos = y2pos - 25; } } //afterTime = System.currentTimeMillis(); //System.out.println("the time to show the image is : " + (afterTime-beforeTime)); }
forgot about this question. I already figured out what's wrong with my code. But I have another question about applet. When I tried to show a moving picture in a applet, the picture always flash. I call repaint() several times to let the picture move, is it the reason why picture flash? Thanks
Don't get me started about those stupid light bulbs.