Reputation: 5
I'm working on a project which uses paintcomponent.
The problem is that this paintcomponent method is executing itself repeatively without asking.
I discovered this problem by creating a counter that raises the method runs everytime and I printed this out. Now is see that the method repeats itself randomly.
The problem is that this makes message boxes etc execute multiple times and freeze.
How can I solve this?
Upvotes: 0
Views: 80
Reputation: 200166
paintComponent
is a low-level method which can be called at any time at the discretion of the GUI engine. It is not a place to instantiate any message boxes or similar, but to use low-level 2D graphics calls to paint your custom component. Your use case may actually call for a different mechanism whereby to refresh your screen.
Upvotes: 2