You've got program logic in your paint or paintComponent method, and that is something that shouldn't be done. These methods should do nothing but paint and should not set the state of the class...