Mi ricordo della Demo che ti avevo fatto e faccio che riprendere quella.
Basta che crei 2 timer impostando setRepeats(false) di modo che non si ripetano e gli assegni lo stessa actionPerformed.
All'interno di actionPerformed fai ripartire o uno o l'altro timer. Per sapere quale timer re-impostare ho utilizzato setActionCommand.
Puoi cambiare a tuo piacimento i tempi agendo su quel 4000 (4 secondi di visualizzazione immagini) e 1000 (1 secondo di black screen).
Nota che ora la variabile booleana blackScreen non serve neanche più.
Ciao.
codice:
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.ImageIcon;
import javax.swing.Timer;
import javax.swing.JLabel;
import java.awt.Toolkit;
import java.awt.Dimension;
class Demo extends JFrame implements ActionListener {
private Timer timer1, timer2;
private JLabel label, label2;
private int imageIndex = 0;
private String s = "C://Documents and Settings//utente//workspace//Progect//src//album//";
private ImageIcon images[][] = {
{ new ImageIcon(s + "1.jpg"), new ImageIcon(s + "2.jpg") },
{ new ImageIcon(s + "3.jpg"), new ImageIcon(s + "4.jpg") },
{ new ImageIcon(s + "5.jpg"), new ImageIcon(s + "6.jpg") },
{ new ImageIcon(s + "7.jpg"), new ImageIcon(s + "8.jpg") }
// qui puoi continuare ad aggiungere altre coppie di icone
};
public Demo() {
label = new JLabel(images[imageIndex][0]);
label2 = new JLabel(images[imageIndex][1]);
label.setBounds(150, 150, 100, 100);
label2.setBounds(350, 150, 100, 100);
add(label);
add(label2);
getContentPane().setBackground(Color.BLACK);
setLayout(null);
//setSize(600, 400);
// fullscreen
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setUndecorated(true);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(0, 0, screenSize.width, screenSize.height);
// creo timer1, timer2
timer1 = new Timer(4000, this);
timer1.setRepeats(false);
timer1.setActionCommand("blackScreen");
timer2 = new Timer(1000, this);
timer2.setRepeats(false);
timer2.setActionCommand("image");
timer1.start();
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("blackScreen")) {
label.setIcon(null);
label2.setIcon(null);
timer2.start();
} else {
imageIndex = imageIndex + 1 >= images.length ? 0 : imageIndex + 1;
label.setIcon(images[imageIndex][0]);
label2.setIcon(images[imageIndex][1]);
timer1.start();
}
}
public static void main(String args[]) {
new Demo().setVisible(true);
}
}