Can't recompile Java project after editing a particular file

Has this ever happened to you?

You are working on a project and at some point, you try to recompile the code and it doesn’t use your changed file. Then you go to a different file and edit it and, all of a sudden, the code begins to successfully recompile when you try again.

This is happening in my Java program. I’m using swing and my JPanel class is the one not registering changes until I edit a different file.

All suggestions on how to fix this issue are welcome! Thanks!