public void actionPerformed(ActionEvent e) {
i++;
ImageIcon icon = new ImageIcon(files[i].getAbsolutePath());
imagem.setIcon(icon);
frame.add(imagem, BorderLayout.CENTER);
}
});
I have an array of images, and the goal is to always press the (event) button, iterator i increments its value by one unit and mute the image.
But when I get to the end of the array (when there are no images), it gives me an error and blocks the program. I know I have to do an if (files.lenght) but I'm not sure where to put it. Someone can help me? Thanks