I took this code straight out of 'Java all in one for Dummies' …why doesn't it work?

前端 未结 2 1215
情话喂你
情话喂你 2021-01-06 03:34
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;


@SuppressWarnings(\"serial\")
public class Picture e         


        
2条回答
  •  逝去的感伤
    2021-01-06 04:20

    Try:

    ImageIcon image = new ImageIcon(getClass().getResource("TestImage.jpg"));
    

    See How to Use Icons tutorial for more details, in particular Loading Images Using getResource section.

提交回复
热议问题