What is the correct path to display an ImageIcon png file for Windows 7?

前端 未结 6 1664
南笙
南笙 2020-12-04 02:20

I wanted to test having a program with a simple png image on it. I wrote a short program that does this, but I can\'t seem to get the path right. I have checked, checked aga

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 02:48

    Using this fixed it for me:

    JButton btnBanana = new JButton("New button");
    btnBanana.setIcon(new ImageIcon("D:\\Android\\Company\\images\\bananas-icon.png"));
    

提交回复
热议问题