{
//ImageIcon icon1 = new ImageIcon("/Users/huangyuxin/Java2/src/AAvvvvv/image/1.JPG");
//JLabel jLabel1 = new JLabel(icon1);
//jLabel1.setBounds(60,60,60,60);
//this.getContentPane().add(jLabel1);
//this.setVisible(true);
this.getContentPane().removeAll();//清空之前的图片
int n = 1;
for(int i = 0; i < 4; i++)
{
for(int j = 0; j < 4; j++)
{
ImageIcon imag = new ImageIcon("/Users/n/Java2/src/A/image/"+n+".JPG");
//JLabel jLabel = new JLabel(new ImageIcon(""));
JLabel jLabel1 = new JLabel(imag);
jLabel1.setBounds(120 * j, 120 * i+1,120,120);
//jLabel1.setBorder(new BevelBorder(1));//将图片设置成嵌入式
this.getContentPane().add(jLabel1);
n++;
}
}
}
先加载一个图片看看,是否是图片路径的问题