import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.Timer; public class Test extends JFrame implements ActionListener{ Toolkit environnement = Toolkit.getDefaultToolkit(); private JPanel panel = new JPanel(); private JLabel label = new JLabel(); private ImageIcon[] tableauImages = new ImageIcon[3]; int compteur = 0; private Timer t; public Test(){ this.setTitle("Menu Principal"); this.setSize(environnement.getScreenSize().width, environnement.getScreenSize().height); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLocationRelativeTo(null); tableauImages[0] = new ImageIcon("./Image1.jpeg"); tableauImages[1] = new ImageIcon("./Image2.jpeg"); tableauImages[2] = new ImageIcon("./Image4.jpeg"); panel.add(label); label.setIcon(tableauImages[compteur]); t = new Timer(10000,this); t.start(); this.setContentPane(panel); this.setVisible(true); } public void actionPerformed(ActionEvent e){ compteur ++; if(compteur > 3) compteur = 0; label.setIcon(tableauImages[compteur]); } public static void main(String[] args) { Test test = new Test(); } }