This is getting on my nerves and it probably something silly on my part but I can\'t figure out why my paintComponent is being called twice, if you run my code it outputs RE
It printed out twice for me too.
However, I don't think it is cause for concern. Swing decides when things need to be repainted. For example, if you resize a window or minimise/maximise, Swing will repaint. It might be dependent on the OS/hardware you are running on.
You should write your code so that it is robust enough to handle multiple calls to repaint
.
Please see this SO question too: paintComponent is executing twice