Bonjour,

Je ne comprends pas pourquoi ce code ne fonctionne pas. C'est pour mettre un texte devant une image de fond :

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
public class Presentation extends JPanel {
	Presentation()
	{
		super();
		setLayout(new BorderLayout());
		add(new JLabel("    "),BorderLayout.WEST);
		JLabel lab=new JLabel("COUCOU");
		//RussellSquare
		lab.setFont(new Font("RussellSquare", Font.PLAIN, 19));
		lab.setForeground(Color.MAGENTA);
		add(lab,BorderLayout.CENTER);
	}
 
	public void paint(Graphics g)
	{
		try {
			BufferedImage image = ImageIO.read(new File("img/croix.jpg"));
			g.drawImage(image, 0, 0, this.getWidth(), this.getHeight(), this);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
Merci pour votre aide