1

I think it should be intuitive, but it is not to me...I wasted 2 hours to search on how to do so but so sad... enter image description here

Please kindly advice on the correct step to change the icon of java program.

manhon
  • 683
  • 7
  • 27
  • See [Sizes of frame icons used in Swing](http://stackoverflow.com/q/18224184/418556) for an example. As to how to do that in Eclipse I have no idea, but you might want to start programming the code, instead of letting the IDE program you. – Andrew Thompson Sep 01 '13 at 10:40

1 Answers1

1

The image should be placed in a source folder. In netbeans I created a folder in my src directory for non-java resources, mostly images. Then a similar dialog box to the one you show above allows me to choose items from this as icons. This should work for eclipse too.

You can also accomplish this just with code where res is a folder inside the src directory.

  try {
     ClassLoader cl = this.getClass().getClassLoader();
     ImageIcon programIcon = new ImageIcon(cl.getResource("res/test.png"));
     setIconImage(programIcon.getImage());
  } catch (Exception whoJackedMyIcon) {
     System.out.println("Could not load program icon.");
  }
Thorn
  • 4,015
  • 4
  • 23
  • 42
  • thank a lot, it works with "test.png"(rather than "res/testpng")! one down side is the icon is loaded only the program open, rather than a nice icon under window file explorer (ie. preview), i wonder if this is the limitation of JAVA program? may be i package it as exe will work. – manhon Sep 02 '13 at 13:17