Icone dans un JLabel s'affiche pas
Bonjour,
voilà comme dans mon titre, l'icon dans mon JLABEL s'affiche pas.
Code:
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 30 31 32 33
|
public class TestImg extends JFrame{
public TestImg(){
URL url;
url = TestImg.class.getResource("images/iconeKO.png");
if (url!=null)
System.out.println("ok");
else
System.out.println("ko");
Icon imgKO=new ImageIcon("images/iconeKO.png");
if (imgKO==null)
System.out.println("null");
//JLabel test=new JLabel("hello",imgKO,JLabel.LEFT);
JLabel test=new JLabel(imgKO);
this.setLayout(new BorderLayout());
Container c=getContentPane();
c.add(test,BorderLayout.CENTER);
this.setSize(800,600);
this.setVisible(true);
}
public static void main(String[] args){
TestImg testImg=new TestImg();
}
} |
merci pour votre aide.
ps: apparemment il trouve bien mon image.