Remove images from JPanel
Hi,
I have a JPanel called imagePanel and a JTree and every time a node is selected in the tree, a set of images are gonna be displayed on the imagePanel
with the loop below. But the next time a node is selected the images that were added via the loop the first time, has to be removed. What code can I use to
empty the imagePanel everytime, before the for-loop runs?
//Some code here to empty the imagePanel so it begins from scratch
for(int index=0; index < imageNames.size(); index++)
{
ImageIcon newImage = createImageIcon("images/" +
(String)imageNames.elementAt(index));
imagePanel.add(new JLabel(newImage));
pictureLabel.setText(null);
}

