Procedure paint ne fonctionne pas
Bonjour,
j ai ma procedure ci :
Code:
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();
}
}
} |
Ce code si marche bien j ai mon image qui s'affiche dans mon panel
une simple image 50px sur 50px
par contre ici
Code:
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();
}
}
} |
ici malheureusement rien ne se passe ,pas d'image dans mon grand panel c'est bizarre
merci d'avance pour votre aide.