开发者

Java Folder Location for Image NetBeans 6.8

开发者 https://www.devze.com 2022-12-24 02:16 出处:网络
开发者_开发问答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:
开发者_开发问答

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

精彩评论

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