1

When I start my application, the icon on the desktop looks like this:

Default Logo for a Java application.

I want to know if there is a way I can change that image to an image of my choosing?

Thomas Fritsch
  • 9,639
  • 33
  • 37
  • 49
ddjh5
  • 67
  • 1
  • 7

2 Answers2

0

Give this a try.

frame.setIconImage(new ImageIO.read(new File("res/game.png")));

where res/game.png is the icon image you want to use

https://docs.oracle.com/javase/7/docs/api/javax/swing/ImageIcon.html#ImageIcon(java.lang.String)

https://docs.oracle.com/javase/tutorial/uiswing/components/frame.html

Derek Lawrence
  • 1,551
  • 2
  • 16
  • 36
0
frame.setIconImage(new ImageIcon(getClass().getResource("logo.png")).getImage()

This works when the image is in the same package as the class. Note: It is better to have images in a resource folder

jaletechs
  • 501
  • 1
  • 7
  • 19