Get image from relative path

前端 未结 8 1921
囚心锁ツ
囚心锁ツ 2021-02-03 13:01

In my project I have 2 packages. images - contain images and notification - contain java files

In notification/main.java I get Image o

8条回答
  •  佛祖请我去吃肉
    2021-02-03 13:26

    I'm using Netbeans to develop Java desktop application and I have solved my problem.

    Image image = new ImageIcon(this.getClass().getResource("/images/bell-icon16.png")).getImage();
    

    "this" is a class extends JFrame

提交回复
热议问题