Problem with updating JPanel.
Hey, I have a program in which I display PNG and GIF images on JPanel. The code for displaying looks like this:
JPanel panel = (JPanel) CurrentStatus.getFrame().getContentPane().getComponent(43);
ImageIcon icon = new ImageIcon(s);
ImageIcon scaledicon = new ImageIcon(scaleIcon(icon.getImage(),850,500));
JLabel label = new JLabel();
The file that is being displayed is deleted from the system's memory after displaying. When I display a different file, the panel changes. However, when I try to display a file with the same name that was displayed beforehand (and deleted afterwards), but with changed parameters, the panel still shows the previous picture.
I tried every JPanel option for removing, revalidating, as you can see in the code, and the file is deleted and I have no idea where does he take the image from.
If I try not deleting the file, the file written in memory is different than the image didplayed.
So, for example: I create an image file in the program named dog.png. I display it on the panel, then I delete the file. After I display another created image file cat.png. The panel's image changes. The file is deleted. Then I create another file named dog.png, but with different parameters than the first dog. In memory the file is written with parameters changed. However, when I try to display it in JPanel, it returns to the previous image with original parameters, even if the file has been deleted previously.
Does anyone have any idea?