Bonjour,
j ai ma procedure ci :
Ce code si marche bien j ai mon image qui s'affiche dans mon panel
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 public class Case extends JPanel{ public Case() { //code } public void paintComponent(Graphics g){ try { Image img = ImageIO.read(new File("ok.jpg")); //g.drawImage(img, 0, 0, this); //Pour une image de fond g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this); } catch (IOException e) { e.printStackTrace(); } } }
une simple image 50px sur 50px
par contre ici
ici malheureusement rien ne se passe ,pas d'image dans mon grand panel c'est bizarre
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 monPanel extends JPanel { public monPanel() { // code } public void paintComponent(Graphics g){ try { Image img = ImageIO.read(new File("ok.jpg")); //g.drawImage(img, 0, 0, this); //Pour une image de fond g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this); } catch (IOException e) { e.printStackTrace(); } } }
merci d'avance pour votre aide.
Partager