I want to be able to change the taskbar button image to a custom image instead of the default Java image.
Asked
Active
Viewed 294 times
1
-
See http://stackoverflow.com/questions/1614772/how-to-change-jframe-icon – exception1 Feb 20 '14 at 01:56
1 Answers
5
Use
ImageIcon img = new ImageIcon(PathToFile);
frame.setIconImage(img.getImage())
Keep in mind if you export it to a jar it will still have the Java coffee cup as its icon.
You can also use Window#setIconImages
which allows you to supply a variety of image sizes which allows the native windowing system to decide which one it would like to use (Thanks MadProgrammer)

GreySwordz
- 368
- 1
- 9
-
2You can also use [`Window#setIconImages`](http://docs.oracle.com/javase/7/docs/api/java/awt/Window.html#setIconImages(java.util.List)) which allows you to supply a variety of image sizes which allows the native windowing system to decide which one it would like to use...makes it look nicer ;) – MadProgrammer Feb 20 '14 at 01:59
-
-
@MadProgrammer Good point. See also [Sizes of frame icons used in Swing](http://stackoverflow.com/q/18224184/418556) & the answer of [mKorbel](http://stackoverflow.com/a/18225431/418556) for a summary of preferred sizes for two Windows set-ups. – Andrew Thompson Feb 20 '14 at 02:34
-