How do I change the default application icon in Java?

后端 未结 10 811
心在旅途
心在旅途 2020-11-27 17:02

I\'m using NetBeans, trying to change the familiar Java coffee cup icon to a png file that I have saved in a resources directory in the jar file. I\'ve found many different

10条回答
  •  無奈伤痛
    2020-11-27 17:19

    You can simply go Netbeans, in the design view, go to JFrame property, choose icon image property, Choose Set Form's iconImage property using: "Custom code" and then in the Form.SetIconImage() function put the following code:

    Toolkit.getDefaultToolkit().getImage(name_of_your_JFrame.class.getResource("image.png"))
    

    Do not forget to import:

    import java.awt.Toolkit;
    

    in the source code!

提交回复
热议问题