I’m using some 3rd party AWT components in a desktop application. The component’s layout is changed within the paint() method, and this causes some very strange behaviour. This appears to be fixed by adding the synchronized keyword to the paint() method, but is this a safe thing to do?
I’m using some 3rd party AWT components in a desktop application. The component’s layout
Share
It looks like the
paint()method is called outside the event dispatch thread, which can indeed cause very strange behaviour, which is why it should never be done.Instead of
paint(), application code should only ever callrepaint()