But before, you should understand that your code has several flaws.

1) the x / y variables are written in the context of your ball-thread and are read in the context of the EDT (Event Dispatch...