I’m using repaint to trigger a SwingWorker. This worker automatically recreates an image to fit the width of the enclosing JPanel according to an autofit option in an application.
The issue is that is causing an Out of Memory Exception. This is because the images have a big resolution and the worker is being called continuously when the window is being drag-resized.
What I’ve tried to avoid this is only execute() when isDone() is true. However I feel there is a better way of doing this. Perhaps by using some sort of timer? What do you suggest?
It’s a little left field, but basically what I do is use a javax.swing.Timer. The basic idea is to only perform an action when the timer fires.