Using the same construct with different values

I have a problem but im not sure how to word it yet, so here it goes.

Here are some sections of my code (the relevant bits anyway):

DrawingWindow dWin = new DrawingWindow( 500,400 , "Anim");

int circleTopLeftX = 5;

int circleTopLeftY = 5;

int circleTopRightX = 95;

int circleTopRightY = 5;

int circleRadius = 5;

int bigMoveRight = 25;

Circle topCL = new Circle (circleTopLeftX ,circleTopLeftY,circleRadius);

Circle topCR = new Circle (circleTopRightX,circleTopRightY,circleRadius);

dWin.draw(topCL);

dWin.draw(topCR);

--

Now say i did:

circleTopLeftX = circleTopLeftX + bigMoveRight;

circleTopRightX = circleTopRightX + bigMoveRight;

I then want to be able to type:

dWin.draw(topCL);

dWin.draw(topCR);

but it just displays the old co-ordinates.

Is there anyway i can refresh it some how?

[926 byte] By [AcidReniXa] at [2007-10-1 0:39:23]
# 1
I'm not exactly sure what you are trying to do. What about calling the Component.repaint() method of DrawingWindow assuming it is a subclass of Component?
tymer99a at 2007-7-7 16:26:20 > top of Java-index,Security,Event Handling...
# 2

ok. it's a university project. We have been asked to create an animation using elements.

The idea is we draw a tile 100 x 100 pixels. Then move that tile around a drawing window 500 x 400 pixels.

This is pretty easy and i can do it no problem.

I kind of did this on my first attempt by adding x, y and radius values to variables and then using:

Circle topCL = new Circle (circleTopLeftX ,circleTopLeftY,circleRadius);

The problem i have, is that to do the second tile (the 2nd frame of the animation) i did exactly the same thing, using the same variables, except i couldn't use the changed variables (circleTopLeftX, circleTopLeftY and circleRadius) in the same circle thing (topCL) because it had allready been constructed.

i had to create a new one with the name "topCL2"

now doing this for around 50 slides is annoying and time consuming.

what i want to do, was to use the new values i had stored into circleTopLeftX etc... and change topCL to use these new values. I would then draw topCL again, but it would be in a different location to the first tile.

ways i can think of doing it (but don't know how):

1) some how delete the construct (topCL) after it had been drawn, then re construct it.

2) refresh topCL so it looks at the new values and uses them after it has been drawn.

Another problem is that we have only been asked to import elemtent.* and java.awt.Color.

If you don't understand it now, i'll try 1 more time to reword it. Bare in mind im terrible at English language and know a very small amount of java at this time.

AcidReniXa at 2007-7-7 16:26:20 > top of Java-index,Security,Event Handling...