I have a swing application in which I display images in a JPanel. If the app is unable to produce the image I want to remove the previous one from the JPanel and replace it
You can simply try calling :
cdPanel.revalidate(); cdPanel.repaint(); // This is required in some cases
instead of
cdPanel.validate();