简体   繁体   中英

Change Java program icon under eclipse window builder

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... 在此处输入图片说明

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

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.");
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM