aspose file tools*
The moose likes Applets and the fly likes the position of component in applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "the position of component in applet" Watch "the position of component in applet" New topic
Author

the position of component in applet

Jeannie Yong
Greenhorn

Joined: Oct 18, 2001
Posts: 19
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.
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
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.
Jeannie Yong
Greenhorn

Joined: Oct 18, 2001
Posts: 19
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));
}
Jeannie Yong
Greenhorn

Joined: Oct 18, 2001
Posts: 19
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
 
 
subject: the position of component in applet