Skip to main content

JPanel / Canvas refreh problems

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2011-01-02

First of all, hi to all, this is my first post in this thread and I just registered because of a problem i'm having with Swing.
Well, I have a Panel inside a Frame which consists of a Canvas that I need to update in real time. Shortly, when you clicks on an option a different image must appear.

I have no problems on displaying the image, but when the user clicks another option, the old image doesn't dissappear, so the new one shows above the old one. I'm trying repaint, removeAll, etc but nothing seems to work.

This is the code of the paintComponent() method:

public void paintComponent(Graphics g){
(...) painting method (...)


Any suggestions? Thanks in advance