How to change java icon in a JFrame

后端 未结 5 1075
渐次进展
渐次进展 2020-12-31 11:54

Ok so I\'ve been researching this one quiet a bit. I am fairly new to java but thought that this one would be easy. Ive tried just about every way that has been answered on

5条回答
  •  悲&欢浪女
    2020-12-31 12:49

    This works pretty fine for me. Just add this after you've created your JFrame.

    try {
       Image image = new ImageIcon("/icons/image.jpg").getImage();
       frame.setIconImage(image);
    }catch(Exception e){
       System.out.println("Application icon not found");
    }
    

提交回复
热议问题