Voici mon code :
classe Main
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
 
public class Main {
 
	public static void main(String[] args) {
		Fenetre fen = new Fenetre();
 
 
	}
 
}
Classe Fenetre
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
import javax.swing.JFrame;
import javax.swing.JPanel;
 
public class Fenetre extends JFrame {
 
	public Fenetre() {
		this.setTitle("Deeper Aquatic 0.1");
		this.setSize(500, 500);
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
		this.setContentPane(new Panneau());
		this.setVisible(true);
 
	}
 
}
Ma classe Panneau
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
 
public class Panneau extends JPanel {
	public void paintComponent(Graphics g ) {
		try {
			Image image1 = ImageIO.read(new File("bleu.jpg"));
			Image image2 = ImageIO.read(new File("rouge.jpg"));
			Image image3 = ImageIO.read(new File("noir.jpg"));
			g.drawImage(image1, 0, 0, this);
			g.drawImage(image2, 0, 0, this);
			g.drawImage(image3, 0, 0, this);
		}catch (IOException e) {
			e.printStackTrace();
		}
	}
	public String getRandom(String[] array) {
		String [] array1 = {"image1", "image2", "image3"};
		int rnd = new Random().nextInt(array1.length);
		return array1[rnd];
	}
 
}
et ça m'affiche que la couleur noir c'est normale ?