progress icon shows in multiple places when scrolling

This commit is contained in:
Vassiliy.Kudryashov
2014-08-18 14:25:55 +04:00
committed by Sergey Simonchik
parent b35c04475b
commit a0e69b8c7c
@@ -71,7 +71,7 @@ public class AsyncProcessIcon extends AnimatedIcon {
return icons;
}
public void updateLocation(JComponent container) {
public void updateLocation(final JComponent container) {
final Rectangle rec = container.getVisibleRect();
final Dimension iconSize = getPreferredSize();
@@ -79,7 +79,14 @@ public class AsyncProcessIcon extends AnimatedIcon {
final Rectangle newBounds = new Rectangle(rec.x + rec.width - iconSize.width, rec.y, iconSize.width, iconSize.height);
if (!newBounds.equals(getBounds())) {
setBounds(newBounds);
container.repaint();
// painting problems with scrollpane
// repaint shouldn't be called from paint method
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
container.repaint();
}
});
}
}