Hi all,
Any help you can give would be greatly appreciated...
I have a JLabel on a JPanel. The JLabel is used to display a picture. It works fine once. However, after the first picture is drawn, I cannot get it to update the picture with subsequant calls.
In my constructor I have:
JLabel theLabel; // The label to display the image
public Constructor() {
/* Add blank image to panel */
visualPanel = new JPanel(); // Create panel
ImageIcon pic = new ImageIcon(); // Create image icon
theLabel = new JLabel(pic, JLabel.CENTER); // Create label
p.setOpaque(true); // Set opaque
visualPanel.add(theLabel); // Add to panel
}
And I have a separate method for updating the picture displayed by theLabel:
public void showFrame(){
ImageIcon pic = new ImageIcon("frame.jpg"); // Load picture
theLabel.setIcon(pic); // Set theLabel's icon
}
So to summarise: I call showFrame once, it displays the picture, I call it again, it doesn't get repainted. I have tried calling paint() on the visualPanel, on its parent panel (not listed above), and on theLabel, but with no luck.
How can I make theLabel repaint with the new ImageIcon? Thanks in advance!