views:

196

answers:

1

greetings, today i have started to learn java using netbeans ide.

i would like my jframe to display an icon as stated in the following:

setIconImage(Toolkit.getDefaultToolkit().getImage("SartreIcon.jpg"));

the questin is under netbeans ide.. exactly in which folder do i place the graphic in question in order to load it?

thanks.

EDIT: solved.

    URL url= getClass().getResource("Resources/SartreIcon.jpg");
    ImageIcon imageIcon = new ImageIcon(url);
    Image image = imageIcon.getImage();
    this.setIconImage(image);

thank you.

+1  A: 
URL url= getClass().getResource("Resources/SartreIcon.jpg"); 
ImageIcon imageIcon = new ImageIcon(url); 
Image image = imageIcon.getImage(); 
this.setIconImage(image);
iEisenhower