why is my code executing paintComponent(Graphics page) twice?

前端 未结 1 791
遇见更好的自我
遇见更好的自我 2020-12-12 04:51

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

相关标签:
1条回答
  • 2020-12-12 05:07

    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

    0 讨论(0)
提交回复
热议问题