Yes, everything inside that method is going to be run on the EDT including any methods that you invoke within paintComponent()
.
And what about other methods inside that same class?
If they are called from paintComponent()
or from actionPerformed()
, etc, then they will also be on the EDT!
What if I call repaint() on the custom JPanel from inside the run() method of a thread I made? Will paintComponent() still be run on the EDT?
repaint()
on a non-EDT thread will schedule a repaint -> paintComponent()
to be run on the EDT. So yes, still on the EDT! Btw, you can test this by placing a break-point in your paintComponent
method and seeing which thread is suspended.