How to add an Image to Form in java

后端 未结 4 1512
梦谈多话
梦谈多话 2021-01-13 22:52

I am designing a form in java using JDeveloper. I am new to JDeveloper. In JDeveloper tool I didn\'t found any option to directly add image to form like .Net. And I don\'t k

4条回答
  •  北海茫月
    2021-01-13 22:56

    You can try doing it this way:

    1. ImageIcon image = new ImageIcon(getClass().getResource("imageName.png"));
    2. JLabel lblImage = new JLabel(image);

    line 1 of the code will get the image ensure that the image is in the same folder you are saving your work

提交回复
热议问题