Java adding ImageIcon to JLabel

后端 未结 3 1537
悲&欢浪女
悲&欢浪女 2021-02-15 14:14

I am trying to make a very basic game with Java and I am having trouble displaying an image on a JFrame. It has worked in the past for me and now is not, i can\'t s

3条回答
  •  滥情空心
    2021-02-15 15:05

    Try,

    ImageIcon image = new ImageIcon("c:\\path\\image.png");
    imagelabel = new JLabel(character, image, JLabel.CENTER);
    frame.add(imagelabel);
    

    Take a look at Tutorial - How to use Icons

提交回复
热议问题