慕森王
首先在“源包”下创建一个包(说图片)将所有图像复制到此程序包(创建程序包时,将在项目src文件夹内创建一个以程序包名称命名的文件夹,因此将图像复制到该程序包中)您可以通过以下方式从程序访问图像范例1: this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/images/yourimagename")));范例2: URL imageurl = getClass().getResource("/images/imagename");//assuming your package name is images Image myPicture = Toolkit.getDefaultToolkit().getImage(imageurl); JLabel piclabel = new JLabel(new ImageIcon( myPicture )); piclabel.setBounds(0,0,myPicture.getWidth(null),myPicture.getHeight(null));现在使用此JLabel piclabel