This content has been marked as final. Show 4 replies
Moderator action: Moved from Java Programming.
It looks like you're trying to tweak old AWT code. Don't override update(Graphics). Swing has a different painting mechanism, and is double buffered by default.
If you're using getGraphics() of a component, don't.
It also looks like you're unaware of Swing's single threaded rule.
If I am to move smaller visual items around, I have to redraw (update) the entire region each pixel move.There's an overload of repaint(...) that saves you from that.
Recommended learning resources:
Brilliant!! People, the answer is the simple approach.
The painting method to override is
protected void paintComponent(Graphics g)
not public void paint(Graphics g)
and not to call paint(Graphics g) or update(graphics g)
but simply repaint();
What genius! Problems solved, flickers gone!! Thank you all!