7

Java Swing applications by default have the Java coffee cup icon appear in the top left corner of the application.

I would like to replace this with my own image - what API is used?

Can this be done at run time, or must something be done at install time?

Thanks!

Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228
bguiz
  • 27,371
  • 47
  • 154
  • 243
  • 4
    Take a look at [ How do I set an Application's Icon Globally in Swing? ](http://stackoverflow.com/questions/103179/how-do-i-set-an-applications-icon-globally-in-swing) and [ How do I change the default application icon in Java? ](http://stackoverflow.com/questions/209812/how-do-i-change-the-default-application-icon-in-java). – Matthew Flaschen Sep 17 '10 at 02:19

2 Answers2

8

JFrame.setIconImage(Image image) does exactly that.

Rotsor
  • 13,655
  • 6
  • 43
  • 57
  • what if I wanted to change the whole application coffe icon instead of just one JFrame? –  Dec 18 '18 at 07:27
4

Look at the setIconImage method.

TofuBeer
  • 60,850
  • 18
  • 118
  • 163
  • @camickr It didn't show up as a dup when I posted it... I just found that out now. – TofuBeer Sep 17 '10 at 14:50
  • 1
    I figured that was the case. When I looked at the question it was answer 14 seconds before I browsed it. The point about a more recent link is another reason why I don't include links to the API. I just point out the method since every programmer should have easy access to the API for whatever version they are using. You can't assume version 5 or 6 is the proper API. – camickr Sep 17 '10 at 15:56