public class Demo extends JFrame{ public Demo() { // TODO Auto-generated constructor stub setBounds(100,100,500,350); setDefaultCloseOperation(EXIT_ON_CLOSE); Container container = getContentPane() ; JLabel l = new JLabel("这是一个展示图片的标签"); //URL url = Demo.class.getResource("huasacm.png"); //Icon icon = new ImageIcon(url); Icon icon = new ImageIcon("src/huasacm.png"); l.setIcon(icon); l.setSize(20,20); container.add(l); setVisible(true); } public static void main(String[] args) { // TODO Auto-generated method stub new Demo(); } }