Hello. I'm back.
I don't actually have a check for when the shape passes the boundary. What I have is floatX which represents its position (and it is actually declared as a float), and I have a (javax.swing.)Timer, which calls repaint() every 25ms. In paintComponent(Graphcs g), you find the following, which increments floatX by (a randomly-set) xSpeed, then sets the centre of the circle to floatX. If the central x crosses the boundary of the JPanel, the speed changes sign. If count is more than 2000, it invokes System.exit(0), so the whole application closes automatically after about 1 min 20 sec.
And you have the same sort of thing for Y.
Now, the circle is set up as radius = 25f, and the setCentreX() method looks like this:
and the drawYourselfSolid method reads:
so I don't think there is anything which actually checks the crossing of the boundary.
The if statements
test when the centre of the circle crosses the left or top boundary of the JPanel, by which time the left side of the circle is 25px beyond the edge of the panel.
So, no, I am not checking for when it corsses the boundary. How ought I to check for crossing the boundary?
No more replies from me before tomorrow morning.
Thank you.
CR