开发者

Java Folder Location for Image NetBeans 6.8

开发者_开发问答

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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜