Bonjour,Voilà mon code :
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
public void setPhoto(String photo) {
        txtPhoto.setText(photo);
        if(txtPhoto.getText().isEmpty()==false){
              ImageIcon icone =  new ImageIcon(txtPhoto.getText());
              img = icone.getImage();
              Image phot=scale(img,panel.getWidth(),panel.getHeight());
              BufferedImage bufImage = new BufferedImage(phot.getWidth(null), phot.getHeight(null), BufferedImage.TYPE_INT_RGB);
              bufImage.getGraphics().drawImage(phot, 0, 0, null);
              ImageIcon icone2 =  new ImageIcon(bufImage);
              JLabel ima = new JLabel(icone2);
              panel.add(ima);
           }
    }
 
    public static Image scale(Image source, int width, int height) {
        /* On crée une nouvelle image aux bonnes dimensions. */
        BufferedImage buf = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
 
        /* On dessine sur le Graphics de l'image bufferisée. */
        Graphics2D g = buf.createGraphics();
        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        g.drawImage(source, 0, 0, width, height, null);
        g.dispose();
 
        /* On retourne l'image bufferisée, qui est une image. */
        return buf;
}
Le souci c'est que netbeans ne m'interpèle pas sur une quelconque erreur alors que l'image ne s'affiche pas dans le panel, une idée ?